Thursday, 19 February 2015

Try to print location on console


i developing jailbreak iphones. reading beginning ios 5 book. currently, have used location code book , changed slightly. change have made in code trying print location on console.

note: don't need gui based solution. , building code in xcode 4.2 , iphone on trying run code has ios 5.0.1 (9a405).

here code:
code:
    int main(int argc, char *argv[])     {        nslog(@"enter in main");                     nsautoreleasepool *pool = [[nsautoreleasepool alloc] init];                     locationappdelegate *loc = [[locationappdelegate alloc] init];                                  [pool drain];                                  nslog(@"exit main");     }                                -(id) init     {        nslog(@"enter in init()");         	        [super init];         	                      locationmanager = [[cllocationmanager alloc] init];         locationmanager.delegate = self;                                   locationmanager.desiredaccuracy = kcllocationaccuracybest;                      nstimer *currenttimer = [nstimer scheduledtimerwithtimeinterval:20.0 target:self                                                                  selector:@selector(action)                                                                   userinfo:nil                                                                     repeats:yes];             	         nslog(@"exit init()");	         	         return self;     }                                -(void) action     {        nslog(@"enter in action");                     [locationmanager startupdatinglocation];                     nslog(@"exit action");     }                                -(void)locationmanager:(cllocationmanager *)manager            didupdatetolocation:(cllocation *)newlocation                   fromlocation:(cllocation *)oldlocation     {        nslog(@"enter in didupdatetolocation");                                  nslog(@"%f",newlocation.coordinate.latitude);                     nslog(@"%f",newlocation.coordinate.longitude);                     [locationmanager stopupdatinglocation];                              nslog(@"exit didupdatetolocation");     } 
now, output visible on screen
2012-03-22 18:26:23.451 location[437:207] enter in main
2012-03-22 18:26:23.533 location[437:207] enter in init()
2012-03-22 18:26:23.609 location[437:207] exit init()
2012-03-22 18:26:23.647 location[437:207] exit main
 

post exact title of book. post author's name (or names). edition book?

code book using? post chapter or section.

there website book? url?

there downloads @ website of code in chapters? if not, post unmodified original code works.


first error: if fopen() statement fails, proceed fprintf file anyway. @ point, file null, , fprintf() won't work. in fact, crash. if doesn't crash there, attempt print error message not produce error message.

second error: when if (!file) true (as when fopen() fails), not write null file, continue executing rest of function if fopen() succeeded. should return when file can't opened, not continue executing if worked.


should spend little more time thinking how test & debug code write. see no nslog's or other output gives progress or debugging messages. see no indication know how use debugger set breakpoints or step through line line. either of have given more information happening.

1 of fundamental aspects of programming knowing how find out what's happening in program. learn applying programs work, i.e. original sample programs in book. when know how use nslog , debugger on working programs, can start modifying programs. if don't know first thing debugging, unable find bugs in modified programs.
 


Forums iPhone, iPad, and iPod Touch iOS 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