Your PHP should return the contents in the variable in a format easily consumed by your Objective-C program, for example JSON. So, for example,
<?php
// retrieve the value of $result variable any way you want. I'm going to just set the literal
$result = "Hello World!";
// now convert to an array
$result_array = array("result" => $result);
// return the json_encoded rendition
echo json_encode($result_array);
?>
That will end up returning a result that looks like:
{"result":"Hello World!"}
Now, that JSON can be consumed by your Objective-C code, e.g.:
NSURL *url = [NSURL URLWithString:@"..."]; // put your URL in here
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
// make sure there wasn't a connection error
if (connectionError) {
NSLog(@"%s: sendAsynchronousRequest error: %@", __FUNCTION__, connectionError);
return;
}
// parse the JSON data
NSError *error = nil;
NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
// make sure there wasn't a JSON parsing error
if (error) {
NSLog(@"%s: JSONObjectWithData error: %@", __FUNCTION__, error);
return;
}
// now grab the "result" value from the dictionary we parsed from the JSON
// make sure to do all UI stuff on the main queue, though
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
self.label.text = jsonDictionary[@"result"];
}];
}];