views:

36

answers:

2
NSData *myRequest = [NSString stringWithFormat:(@"&site=%@&key=%@",tmpSite,tmpKey)];

Why is this not working ?

Thanks

+7  A: 

Problem is that you are assigning NSString instance to variable of NSData type. Try this:

NSString* s = [NSString stringWithFormat:@"&site=%@&key=%@",tmpSite,tmpKey];
NSData* d = [s dataUsingEncoding:NSASCIIStringEncoding]; //or any other encoding!
Hemant
+1  A: 
NSData *myRequest = [[NSString stringWithFormat:(@"&site=%@&key=%@",tmpSite,tmpKey)] dataUsingEncoding: NSASCIIStringEncoding];

You can't just mix the two classes like that.

Thomas Clayson