Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ct2k7

macrumors G3
Original poster
Aug 29, 2008
8,383
3,439
London
Hi, how do I properly form this if statement?

Code:
[COLOR=#000000][COLOR=#666666][I] if (!selectedCell) { 
  NSString *urlAddress = @"[URL]http://www.google.com[/URL]";}
 else {
  NSString *urlAddress =[[NSBundle mainBundle] pathForResource:@"selectedCell" ofType:@"htm"];}[/I][/COLOR][/COLOR]

Thanks;)
 
keep in mind there is a scope for variables. Once you have allocated & initialized those strings than they are freed. You need to created the urlAddress outside of the if and else command.

Code:
NSString *urlAddress = [NSString string];

 if (!selectedCell) { 
  urlAddress = @"http://www.google.com";}
 else {
  urlAddress =[[NSBundle mainBundle] pathForResource:@"selectedCell" ofType:@"htm"];}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.