Why doesn't this work on my device?
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