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];
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 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];
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 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 8 years ago.
Improve this question
Hi I have declared a method in one of my classes called HttpWorker. The method declaration is
-(void) setRequestParameters:(NSString *)parameters iRequestCode:(double)iRequestCode initialSleep:(long)initialSleep;
I am using trying to call this method from another class called NetManager. I wrote following code for this
NSString *paramStr = #"jc=2";
HttpWorker *httpWorker = [[HttpWorker alloc] init];
double requestCode = [[NSDate date] timeIntervalSince1970];
[httpWorker setRequestParameters:paramStr iReqeustCode:requestCode initialSleep:initialSleep];
But when I compile my code, xcode gives me following warning.
warning: 'HttpWorker' may not respond to '-setRequestParameters:iRequestCode:initialSleep:'
Can anyone please tell me where i am wrong?
Thanks and Best Regards
You have a typo:
iReqeustCode:
Should be:
iRequestCode:
Also you have not defined initialSleep. That should result in compile error!