• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why doesn't this work on my device?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why doesn't this work on my device?


  • Subject: Why doesn't this work on my device?
  • From: James Cicenia <email@hidden>
  • Date: Thu, 26 Feb 2009 15:37:41 -0600

Here is the code. It works on the simulator:


-(NSMutableArray *)statesWithinMiles:(NSString *)miles{
NSMutableArray *states = [[NSMutableArray alloc]init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];


NSString *path = [documentsDirectory stringByAppendingPathComponent:@"whatsfresh.sql"];

if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
sqlite3_create_function(database, "distance", 4, SQLITE_UTF8, NULL, &distanceFunc, NULL, NULL);
NSString *tmp = @"SELECT DISTINCT state_abbr as state FROM geoinfo WHERE distance(Latitude, Longitude, ";
tmp = [tmp stringByAppendingString:[self currentLatitude]];
tmp = [tmp stringByAppendingString:@","];
tmp = [tmp stringByAppendingString:[self currentLongitude]];
tmp = [tmp stringByAppendingString:@") < "];
tmp = [tmp stringByAppendingString:miles];
tmp = [tmp stringByAppendingString:@" and state_abbr NOT NULL ;"];

const char *sql = [tmp cStringUsingEncoding:NSUTF8StringEncoding];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
char *str = (char *)sqlite3_column_text(statement, 0);
[states addObject:(str) ? [NSString stringWithUTF8String:str] : @""];
}
}
}
return states;
}



Why doesn't this work on the device? Help this is causing me hours of grief with errors like these.

Thanks from a noobie who is almost there.

James
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Why doesn't this work on my device?
      • From: Greg Parker <email@hidden>
    • Re: Why doesn't this work on my device?
      • From: Jason Foreman <email@hidden>
  • Prev by Date: Custom Hit Testing with thousands of NSTextView's & cursorUpdate:
  • Next by Date: Re: makeKeyAndOrderFront Crashing
  • Previous by thread: Custom Hit Testing with thousands of NSTextView's & cursorUpdate:
  • Next by thread: Re: Why doesn't this work on my device?
  • Index(es):
    • Date
    • Thread