Dearest stackoverflow brains, I’m having some trouble with iOS again… I am new to this all though.
I’m trying to open a safari with a url, that includes a URL parameter based on the value of the table cell. So if the table cell contained “stack”, I want to go to “http://stack.com?param=stack”. This should be a simple task, but I’m having trouble getting it to work.
It’s failing before I even get to the UIApplication line… so I don’t even know if that will work. I’m getting this error:
2011-10-14 10:18:32.297 NPT[1085:207] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '*** initialization method -
initWithCharactersNoCopy:length:freeWhenDone: cannot be sent to an abstract object of
class NSCFString: Create a concrete instance!'
When I use this code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString* thisValue = [[[self.searchResults cellForRowAtIndexPath:indexPath] textLabel] text];
NSString* thisPlateURL = [
[NSString new]
initWithFormat:@"http://www.site.co.uk?®no=%@", thisValue
];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: thisPlateURL]];
[thisPlateURL release];
}
I’m guessing it’s something to do with me not setting thisValue properly, and I’m sure I’ll kick myself if someone spots it, but I just don’t see what the problem is.
Please help!
I think that the problem is in NSString initialization:
try with: