i have a button on a view controller and i want to click the button and it goes to a web site. the website is held on parse.com.
the code as follows
- (IBAction)WebAddressBtn:(id)sender {
NSString *url = [self.exam objectForKey:@"Website"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
NSLog(@"website: %@",url);
}
the NSLog
shows Null for the value url
but the data is held at
self.exam objectForKey:@"Website"
NSLog confirms its there
this works and will go to google
- (IBAction)WebAddressBtn:(id)sender {
NSString *url = @"http://www.google.com";
//[self.exam objectForKey:@"Website"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
NSLog(@"website: %@",url);
}
if i try
NSURL *url = [self.exam objectForKey:@"Website"];
url is still showing as Null but i know the data is in self.exam objectForKey:@"Website
NSLog Output for data
name = "DMK Media & Photography Ltd";
phone1 = 01993835148;
phone2 = 07795966848;
postcode = "OX28 4BT";
products = "<PFRelation: 0x10dc75320>(<00000000 00000000>.(null) -> products)";
website = "http://www.dmkmedia.co.uk";
[UIApplication sharedApplication] openURL wont work properly if it doesnot have properly formatted url. Please check whether your url has "http://"