Wrox Programmer Forums

Need to download code?

View our list of code downloads.

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 June 25th, 2012, 12:31 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Coding in Chapter 2

My code does't match the code in the book. I don't know why. Can you please help!
Reply With Quote
  #2 (permalink)  
Old June 25th, 2012, 03:44 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

Some specifics will be needed if you would like some help. i.e. with what page or pages in the book are you finding discrepancies? How is your code different? Are you referring to template generated code not matching the book's code?

Bob
Reply With Quote
  #3 (permalink)  
Old June 25th, 2012, 03:46 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes that's what I mean
Reply With Quote
  #4 (permalink)  
Old September 9th, 2012, 01:55 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation MindPlayer.m page 120

In the book beginning ios game development..
at page 120 in MindPlayer.m I dont know why does the author write Peg* peg=nil;
the author doesnt explain the command nil .
Does anybody can explain this?
Reply With Quote
  #5 (permalink)  
Old November 7th, 2012, 09:25 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

Actually it is not necessary to set the ivar to nil, since this is done automatically. For example if you did the following

Code:
    Peg *peg1 = nil;
    Peg *peg2;
    
    NSLog(@"peg1 = %@ at address %p",peg1,peg1);
    NSLog(@"peg2 = %@ at address %p",peg2,peg2);
The output would be
2012-11-07 08:08:21.977 TestNil[1133:c07] peg1 = (null) at address 0x0
2012-11-07 08:08:21.980 TestNil[1133:c07] peg2 = (null) at address 0x0

nil is the address 0x0. Messages can be safely sent to nil since they are just ignored.

Only when you alloc and init it do you get an address other than nil

Code:
    peg1 = [[Peg alloc] init];
    peg1.color = 'r';
    NSLog(@"peg1 = %@ at address %p",peg1,peg1);
2012-11-07 08:08:21.981 TestNil[1133:c07] peg1 = <Peg: 0x743ff30> at address 0x743ff30

If a variable is a type, not an ivar, it is not safe to fail to initialize it. For example

Code:
    int i;
    int j = 0;

    NSLog(@"i is %d at address %p",i,&i);
    NSLog(@"j is %d at address %p",j,&j);
Both i and j are given an address in memory, and what ever was in that memory address before will provide a garbage value.

2012-11-07 08:08:21.982 TestNil[1133:c07] i is 6045295 at address 0xbfffdb64
2012-11-07 08:08:21.983 TestNil[1133:c07] j is 0 at address 0xbfffdb60

The value of i in this case is unpredictable.

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
Convert DAO Coding to ADO Coding udaybg1 VB How-To 0 August 9th, 2011 09:50 AM
Coding Help sugunakar Classic ASP Professional 2 March 30th, 2008 05:42 PM
help with coding mastrgamr C++ Programming 15 November 10th, 2006 07:55 AM
Help coding here Scoob PHP How-To 3 January 26th, 2006 11:18 AM



All times are GMT -4. The time now is 10:21 AM.


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