|Aug 8, 2012, 02:23 AM||#1|
update my core data database
I must to copy datas from my external database to core data and I have a little problem.
I use Json to communicate with iOS and it's work pretty well, each package of datas have an ID number.
I just want to save this datas in the iphone if the ID number is not saved yet on my IOS database.
How can I do?
|Aug 8, 2012, 01:02 PM||#2|
You might want to look at NSExpression. Something similar to:
NSExpression * expressionDescriptionCount = [NSExpression expressionForFunction:@"count:" arguments:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:@"IDnumber"]]]; [fetchRequest setResultType:NSDictionaryResultType]; NSArray * results = [theContext executeFetchRequest:fetchRequest error:&error];
If the value of the count key inside the dictionary is zero then your "id Number" is not yet present. Otherwise it will be the the nubmer of occurrence.
Ensure you match the string @"IDnumber" in expressionForKeyPath:@"IDnumber" with the correct spelling of the attribute.
Fuel Log Evo: The Cost Manager App for any Vehicle
|Aug 8, 2012, 03:19 PM||#3|
I don't understand the code you posted. You create an NSExpression object, and then you issue a fetch request that doesn't use the expression at all. Aren't you missing code that would add the expression to a predicate, and add the predicate to the fetch request? As written, the code uses an existing fetch request that has nothing to do with the expression object you created.
Duncan Champney, WareTo.
Check out our latest iOS app, Face Dancer, available for free on the App Store.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Core Data do you have to pull out an object before you can update it?||whitedragon101||iPhone/iPad Programming||3||Feb 23, 2014 05:13 PM|
|Combo Core Data Fetch? (Update: Unsupported function expression count)!?||ArtOfWarfare||iPhone/iPad Programming||5||Jul 8, 2013 01:21 AM|
|How to refresh/update Core Data transient property?||mdhansen5||iPhone/iPad Programming||2||Aug 5, 2012 12:46 AM|
|Add or delete Core Data entries in an update?||isthisonetaken||iPhone/iPad Programming||1||Jul 30, 2012 11:24 AM|
|Using Core Data to fetch record from SQLite database.||kimbebot||iPhone/iPad Programming||3||Jun 29, 2012 10:04 AM|
All times are GMT -5. The time now is 02:46 PM.