Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How I can create a WHERE NOT IN condition by using NSPredicates?
I want to fetch all the records those are not already fetched by user.
Following Code solved my problem.
NSMutableArray *lodedRecords = [[NSMutableArray alloc] init];
[lodedRecords addObject:#"ali"];
NSPredicate *notInPredicate = [NSPredicate predicateWithFormat:#"NOT (firstName IN %#)",lodedRecords];
CKQuery *query = [[CKQuery alloc] initWithRecordType:recordType
predicate:notInPredicate];
CKQueryOperation *queryOperation = [[CKQueryOperation alloc] initWithQuery:query];
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
nsnumber *totaldur=0;
totalDur+=(NSNumber*)[dict valueForKey:#"tracktime"];
You can't perform addition on NSnumber for this
NSNumber * totaldur =[NSNumber numberWithInteger:20];
totaldur = [NSNumber numberWithInteger:([number1 integerValue] + [[dict valueForKey:#"tracktime"] integerValue])];
//// first of all convert both numbers to same data type like (nsinteger,int,float) and then apply addition on them and in the end save sum in nsnumber object
Hope it helps
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I know setting a variable conditionally is valid:
someProperty = [anObject aFunctionThatReturnsBool]? #"Yes" : #"No";
This question has an answer that details the use of ternary statements in preprocessor macros
#define statusString (statusBool ? #"Approved" : #"Rejected")
and within a string formatting method
[NSString stringWithFormat: #"Status: %#", (statusBool ? #"Approved" : #"Rejected")]
But what about within any method?
[NSNumber numberWithInt:(aVariableThatCouldBeSet)? 100 : 0)];
And conditional method calling?
[anObject aFunctionThatReturnsBool]? [self doThis] : [self doThat];
Bonus points for any other uses not listed.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want to check if an NSString ends with 19xx or 20xx, with the x's being any valid numbers.
How can I do this?
Sounds like a predicate with a regular expression fits your bill:
NSString *str = #"2013";
NSPredicate *yearPredicate = [NSPredicate predicateWithFormat: #"SELF MATCHES '(19|20)[0-9]{2}'"];
BOOL matched = [yearPredicate evaluateWithObject: str];
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want to put in string int and text.
I have this code: chipsS = [NSString stringWithFormat:#"%i", chips];
What to do?
stringVariable = [NSString stringWithFormat:#"%i - %#", intVariable, stringVariable];
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have in tableView NSMutableArray "days" which contain 6 NSMutableArray (monday, tuesday...saturday)
Before I doing sort,this method is work
tuesday = [NSMutableArray arrayWithArray:[tuesday sortedArrayUsingComparator:^(id cont1, id cont2) { return [[(Lesson *) cont1 time1] compare:[(Lesson *) cont2 time1]]; }]];
but now I must doing [days objectAtIndex:0]=.... but how I do this if this expression is unacceptable
You can not assign an object to a NSMutableArray with the equal sign, use the following:
[days addObject:theObjectYouWantToAdd];
EDIT:
In case you would like to add the new object to a particular position on the original mutable array (say position 0), you have to remove the old one by:
[days removeObjectAtIndex:0];
Ant then insert the new one by:
[days insertObject:theObjectYouWantToInsert atIndex:0];