Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stringByAppendingString

I am using Xcode 4.2 storyboard. I am stuck in this concatenation. Is this right? Where in the code i've to modify? actually i want to display a new tableview depending on the variable passed ("row") from previous tableview. Any help appreciated.

self.newrow =row;// row is the variable passed from previous tableview

NSString *urlString = [NSString stringWithFormat: @"http://ipaddress/iphone.php?id="];

NSString *urlStr=@"";
urlStr=[urlString stringByAppendingString:newrow];

NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection release];
[request release];
like image 468
jason Avatar asked Dec 19 '11 12:12

jason


1 Answers

Since self.newRow is an integer change your code to:

NSString *urlStr = [urlString stringByAppendingFormat:@"%i", self.newrow];

The format converts the integer to a string representation.

Several statements can be combined without loosing clarity:

NSString *urlString = [NSString stringWithFormat: @"http://ipaddress/iphone.php?id=%i", self.newrow];
like image 130
zaph Avatar answered Sep 26 '22 18:09

zaph