Results 1 to 1 of 1

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: [Help!] iPhone run a binary file form terminal !

  1. #1
    i use Xcode build a app and i copy the app's binary file put it on my iPhone and run it form terminal.
    i want the binary printf out "location is enable" and my location.
    but it just printed "location is enable"
    so i try to test on iPhone by Xcode. it worked.
    i want to know what's the problem ?
    please help me.

    here is the code



    #import <Foundation/Foundation.h>
    #import <CoreLocation/CoreLocation.h>

    @interface NSObject(CB)
    - (void)logLonLatCLLocation*)location;
    - (void)locationManagerCLLocationManager *)manager
    didUpdateToLocationCLLocation *)newLocation fromLocationCLLocation *)oldLocation;
    - (void)locationManagerCLLocationManager *)manager didFailWithErrorNSError *)error;
    @end

    @implementation NSObject(CB)
    - (void)logLonLatCLLocation*)location
    {
    CLLocationCoordinate2D coordinate = location.coordinate;
    NSLog(@"latitude,logitude : %f, %f", coordinate.latitude, coordinate.longitude);
    NSLog(@"timestamp : %@", location.timestamp);
    }

    - (void)locationManagerCLLocationManager *)manager
    didUpdateToLocationCLLocation *)newLocation fromLocationCLLocation *)oldLocation {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [self logLonLat:newLocation];
    [pool drain];
    }

    - (void)locationManagerCLLocationManager *)manager didFailWithErrorNSError *)error{
    NSLog(@"Error: %@", error);
    }
    @end

    int main(int ac,char *av[])
    {
    id obj = [[NSObject alloc] init];
    id lm = nil;
    if ([CLLocationManager locationServicesEnabled]) {
    printf("location service enabled\n");
    lm = [[CLLocationManager alloc] init];
    [lm setDelegatebj];
    [lm startUpdatingLocation];
    }

    CFRunLoopRun();
    [lm release];
    [obj release];
    return 0;
    }
    Last edited by suutaku; 07-07-2013 at 11:22 PM.

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