Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am having an NSString object as "HAI HELLO ABC".I want it to "HAIHELLOABC".Is there any function present?
[str stringByReplacingOccurrencesOfString:#" " withString:#""];
NSString * newString = [string stringByReplacingOccurrencesOfString:#" " withString:#""];
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
NSDictionary *latestCollection=[json objectWithString:responseString error:&error];
NSDictionary *data=[latestCollection valueForKey:#"results"];
if([data count]>0 && data!=nil)
{
arrayAddress=[[NSMutableArray alloc]initWithArray:[data valueForKey:#"formatted_address"]];
/*********Showing address of new location******/
[lblAddress setText:[NSString stringWithFormat:#"%#",[arrayAddress objectAtIndex:0]]];
[lblPickUpAddress setText:[NSString stringWithFormat:#"%#",[arrayAddress objectAtIndex:0]]];
}
else
{
NSLog(#"Address not available");
}
Your problem is your if clause:
if([data count]>0 && data!=nil)
if will evaluate from left to right, so first, it accesses data for the count, but it may be nil, so simply switch the expressions like so:
if( data!=nil && [data count]>0)
the if clause will stop, as soon as one of the expressions if false, so it will do a check for nil, if its NOT nil, then it will access data to get the count. If data is nil, then the data will not be accessed. Thats why your app crashes.
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 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 does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
-(IBAction)button:(id)sender{
If (cardsinplay >= 16){
NSNumber *cardValue = carsAndValue[14];
NSInteger *Value = [cardValue integerValue[;
From what i know this should read the NSNumber from the array and change it into a NSInteger
But i get this error.
Incompatible integer to pointer conversion initialization 'NSInteger*'(aka 'int*') with an expression of type 'NSInteger'(aka 'int*')
-[NSNumber integerValue] returns a NSInteger, not a pointer to one.
NSInteger *Value = [cardValue integerValue];
should be
NSInteger value = [cardValue integerValue];
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];