Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2012, 11:31 AM
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!
 
Old June 25th, 2012, 02: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
 
Old June 25th, 2012, 02: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
 
Old September 9th, 2012, 12: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?
 
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




Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert DAO Coding to ADO Coding udaybg1 VB How-To 0 August 9th, 2011 08:50 AM
Coding Help sugunakar Classic ASP Professional 2 March 30th, 2008 04: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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.