Re: Why doesn't this work on my device?
Re: Why doesn't this work on my device?
- Subject: Re: Why doesn't this work on my device?
- From: James Cicenia <email@hidden>
- Date: Thu, 26 Feb 2009 16:53:20 -0600
First off thank you for answering....
Well unfortunately,,, this problem is more than in this bit of code.
Here is a snippet where the statesArray never gets filled. It works
great
in the simulator.
I think I am missing some key retain or such..
statesArray is synthesized and properly setup in my .h file with:
NSMutableArray *currentStates;
@property (nonatomic, copy) NSMutableArray *statesArray;
Now I have tried about four variations on this code and nothing seems
to make a difference.
Thanks
James
- (void)statesForItemAndMonthAndFresh:(NSString *)itemName month:
(NSString *)month fresh:(Boolean)fresh{
Sqlite *sqlite = [[Sqlite alloc] init];
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory
stringByAppendingPathComponent:@"whatsfresh.sql"];
if (![sqlite open:writableDBPath]) return ;
if(fresh){
NSArray *results = [sqlite executeQuery:@"SELECT DISTINCT
AvailableItem.state FROM AvailableItem, ProduceItem where
AvailableItem.hotHouse = 'FALSE' AND AvailableItem.produceItemID =
ProduceItem.id AND ProduceItem.name = ? and AvailableItem.month
= ?;",itemName,month];
for (NSDictionary *dictionary2 in results) {
[self.statesArray addObject:[dictionary2 objectForKey:@"state"]] ;
}
}else{
NSArray *results = [sqlite executeQuery:@"SELECT DISTINCT
AvailableItem.state FROM AvailableItem, ProduceItem where
AvailableItem.hotHouse = 'TRUE' AND AvailableItem.produceItemID =
ProduceItem.id AND ProduceItem.name = ? and AvailableItem.month
= ?;",itemName,month];
for (NSDictionary *dictionary2 in results) {
[self.statesArray addObject:[dictionary2 objectForKey:@"state"]] ;
}
}
[sqlite release];
}
On Feb 26, 2009, at 4:14 PM, Jason Foreman wrote:
On Thu, Feb 26, 2009 at 3:37 PM, James Cicenia <email@hidden>
wrote:
Why doesn't this work on the device?
Help this is causing me hours of grief with errors like these.
What errors? You haven't shown any, just code. Define "doesn't work"
and you'll get better help.
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
Use -fileSystemRepresentation, not -UTF8String. Are you sure the file
exists where you think it does?
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
;"];
-stringByAppendingFormat might clean this up.
Jason
_______________________________________________
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
_______________________________________________
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