Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning iOS Game Development
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning iOS Game Development
This is the forum to discuss the Wrox book Beginning iOS Game Development by Patrick Alessi ; ISBN: 978-1-1181-0732-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS Game Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 4th, 2012, 06:51 AM
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default about magicMind, target integrity error

i`ve downloaded the source zip file from wrox site and ..

opened the magicmind project from the unzipped folder.

but unfortunately the code does not run appropriately.

here is the screenshot of the error.

(it says some kind of integrity error. )

http://cfile25.uf.tistory.com/image/...4F042A0D137E5C



still, the code i`had typed myself succeeded to run.

but when i put in like "bbyy" in console, it gives me another error.

below is the screen shot of it.

http://cfile26.uf.tistory.com/image/...4F042B882C4AE0


i`ve checked many times but nothing is wrong.

please check this for me. i`m kinda stuck on this.
Reply With Quote
  #2 (permalink)  
Old January 4th, 2012, 08:55 AM
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok i`ve solved the second error from the file that i typed myself.

if i add the code below to the start and end of the int main the autorelease error doesnt show up.

int main (~)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

~~

[pool release];
return 0;
}

it seems that this is about the arc setting.
Reply With Quote
  #3 (permalink)  
Old January 5th, 2012, 03:07 AM
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

and this works well too.


int main (~){
@autoreleasepool{
~codes ~
}
return 0;
}

this is the code that xcode show me after i make a commandline project.

i am wondering this is problem about my xcode which is not from app store.
its version is 4.2 and the build num is 4C199.
if somebody is in the same problem with me which is that you are using a xcode 4.2
but cannot compile commandline program with arc,
then check out your xcode build number.
Reply With Quote
  #4 (permalink)  
Old January 8th, 2012, 02:27 PM
Authorized User
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Location: Ottawa, On, Canada
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Typing the code from the book worked for me using 4.2.1 from the app store however I did receive some warnings in the console that I'm not sure about.

objc[255]: Object 0x1001140a0 of class Peg autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[255]: Object 0x100114440 of class Peg autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[255]: Object 0x100114450 of class Peg autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[255]: Object 0x100114460 of class Peg autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

Other than those warnings, the code built and ran fine however.

In your case do you have ARC on? If you have ARC on and try to use the code you posted it will not build and will tell you that those commands don't work with ARC enabled on your project so I'm guessing that you don't have it enabled on your project?
Reply With Quote
  #5 (permalink)  
Old January 8th, 2012, 03:01 PM
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

objc[255]: Object 0x1001140a0 of class Peg autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[255]: Object 0x100114440 of class Peg autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[255]: Object 0x100114450 of class Peg autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[255]: Object 0x100114460 of class Peg autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug


yeah, these error is the reason why i posted this thread. i got the same error like the one above and compiling is working.
but i know that memory management was and is still a great issue in development in ios apps. so i think this should be explained exactly.

and i think your project is not set to arc like me, i guess. if the arc working, then that means your arc is successfully managing memory
and you should get no warning about memory setting.

anyway i don`t know why the book has not referred anything about autorealsepool parenthesis in main function. i could get information through google searching but a little confusing.

Last edited by baryonicdm; January 8th, 2012 at 03:05 PM.
Reply With Quote
  #6 (permalink)  
Old January 8th, 2012, 03:32 PM
Authorized User
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Location: Ottawa, On, Canada
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I do have ARC enabled in my project. I did try to manually manage memory allocation but that's when I ran into issues with warnings about not building with ARC enabled.

It would be nice if someone could chime in to let us know why these warnings appear.
Reply With Quote
  #7 (permalink)  
Old January 8th, 2012, 11:10 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

When you create a Command Line Tool of type Foundation, which I assume the book asks you to do (I don't have the book… yet) and you have the Use Automatic Reference Counting box checked, the template should provide you with the follow main.m file… (Xcode 4.2.1 (4D502) for Mac OS X 10.7)


Code:
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

    @autoreleasepool {
        
        // insert code here...
        NSLog(@"Hello, World!");
        
    }
    return 0;
}
The @autorelease block is already set up, and you just enter your code between the block's braces. retain and release cannot be used if ARC is enabled. This block is in the template whether or not the Use Automatic Reference Counting box is checked. This replaces the previous template which used
Code:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

[pool release];
The @autorelease block must be used with ARC, since you can not explicitly send retain or release messages.

Without the block there is no autorelease pool so memory leaks. Warnings are not errors so programs will compile and run. However, the memory leaks are a crash waiting to happen.

The download available is missing the @autorelease block, which suggests that it may have originally been written without ARC and then converted. (Edit>Refactor>Convert to Objective-C ARC) This process will make changes to the retain/release code but does not add the @autorelease block.

The templates may be different for earlier versions of Xcode, and require the addition of the @autorelease block.
Bob
Reply With Quote
The Following User Says Thank You to thepianoguy For This Useful Post:
TH0MAS (January 8th, 2012)
  #8 (permalink)  
Old January 8th, 2012, 11:15 PM
Authorized User
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Location: Ottawa, On, Canada
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks for the explanation Bob. The templates do indeed include that code but the book says to delete the code there and then type in the code from the book which doesn't have that. I may try putting that code back to see if it rectifies the warnings. I do think you're correct though and it is an oversight in the book.
Reply With Quote
  #9 (permalink)  
Old January 8th, 2012, 11:24 PM
Authorized User
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Location: Ottawa, On, Canada
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Ok I just tried it and by adding back in the @autoreleasepool clears all the warnings.

I just double checked my book and the code in the book on page 129 is missing the @autoreleasepool for the code in the main function which results in the memory warnings.

Thanks Bob!
Reply With Quote
  #10 (permalink)  
Old January 9th, 2012, 09:48 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

The only reason I can think of for the omission of the autorelease pool is the fact that he uses C arrays instead of NSArrays in the project. The autorelease under manual reference counting would be in the Peg class method +(Peg *)pegWithColor:(char)theColor, and you can add your @autorelease block to this method to silence the warnings as well, omitting it in main.m. If the Pegs were added to an NSArray they would be retained by the array and released by the class method. This is more correct since the array, not the class should "own" the Peg. The Pegs are not retained by the C array, so with the autorelease pool in place there may be a possibility that the Peg may be released before the program is through with it. I would need to review the ARC mechanics to see if this is likely.
If you haven't watched the WWDC video on ARC I would recommend it.

Bob
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Referntial Integrity ajabbabahalmigiriha Reporting Services 0 October 26th, 2007 12:02 PM
Pivot Tables Integrity Error? Wazar Excel VBA 0 February 20th, 2007 01:00 PM
xml referential integrity mescalito XML 0 December 10th, 2004 08:33 AM
Referential Integrity owain SQL Language 2 May 12th, 2004 04:36 AM



All times are GMT -4. The time now is 12:56 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.