Use stringWithFormat:
NSString *displayAddress = [NSString stringWithFormat:@"address: %@", [object objectForKey:@"address"]];
Pregunta
I working with Qualcomm beacons right now and using the visit.transmitter.name
to identify what object I want in my Parse DB. It seems to be working since the logs are displaying the data but not sure how to use @"address: %@", [object objectForKey:@"address"]
in an alert view so its the title. My equalTo:(@"%@",visit.transmitter.name)];
is also getting an error of Expression Result Unused
PFQuery *query = [PFQuery queryWithClassName:@"houses"];
[query whereKey:@"name" equalTo:(@"%@",visit.transmitter.name)];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
NSLog(@"address: %@", [object objectForKey:@"address"]);
NSLog(@"url:: %@", [object objectForKey:@"url"]);
NSString *displayAddress = [object objectForKey:@"address"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:displayAddress
message:@"THIS WOULD BE THE TITLE, DESCRIPTION"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:@"THIS WOULD BE THE URL"];
[alert show];
}
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
Solución
Use stringWithFormat:
NSString *displayAddress = [NSString stringWithFormat:@"address: %@", [object objectForKey:@"address"]];