Friday, 25 February 2011

newbie Help Question


im triyng learn code xcode

got book beginning objective c programming - tutorials beginner
(http://www.amazon.com/gp/product/b006ogb8zk/ref=kinw_myk_ro_title) , has me starting out doing simple addition program. mac os console
code:
 #import <foundation/foundation.h>  int main (int argc, const char * argv[]) {          nsautoreleasepool * pool = [[nsautoreleasepool alloc] init ];         // insert code here...         //declare , intialize variables                           int firstnumber=2;         int secondnumber=3;         int totalsum=0;         firstnumber=firstnumber+1;         secondnumber=secondnumber+1;         totalsum=firstnumber+secondnumber;         nslog(@"%d",totalsum);         nslog(@"the program has terminated successfully.");          [pool drain];                           return 0;     } 
it returns error nsautoreleasepool unavailable.

know program attempting do. trying output result of 7 , program has terminated in console window.

ideal why resulting in error , how can fix it.
 

that looks old-style autorelease code. old book?

try doing this:
code:
 @autoreleasepool {          program          code goes here      }
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment