objective-c : if statement not working properly -


this isn't whole code i'm trying textview box , see if value has been put in. if not want first bit if not want go else... whatever crashes or doesn't work.

-(ibaction) sendpressed{      if((youtubeurl.text = @"")){         //if doesnt have value         nslog(@"no youtube clip");         youtubelink = @"";     }     else{         //if youtube url has been entered         nslog(@"youtube clip found");         completeurl = youtubeurl.text;         youtubelink = [completeurl substringfromindex:16];     } 

your if statement performing assignment. intend performing comparison. also, should not use == comparison of nsstrings. try this:

- (ibaction)sendpressed {     if([youtubeurl.text isequaltostring:@""]) {         //if doesnt have value         nslog(@"no youtube clip");         youtubelink = @"";     }     else{         //if youtube url has been entered         nslog(@"youtube clip found");         completeurl = youtubeurl.text;         youtubelink = [completeurl substringfromindex:16];     } } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -