Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-16-2011, 04:03 PM   #1 (permalink)
iPhone Developer
 
alex5776's Avatar
 
Join Date: May 2011
Location: Minnesota
Age: 14
Posts: 26
alex5776 is on a distinguished road
Question TextField help

What is wrong with this code?
Code:
if (Titlebox.text == nil) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Missing Title..." message:@"Please Enter A Name Into The Title Box!" 
                                                       delegate:self  cancelButtonTitle:@"Ok, OK!"   
                                              otherButtonTitles:@"OK", nil]; 
        [alert show];
        [alert release];
        
    }
    else{
        NSLog(@"Saving the current file. File Name is > %@ <. ", Titlebox.text);
        
    }
I am trying to have the user save a file, but I want them to title it first. So I have the code look at the textbox to see if it has anything in it.
I have tried this too
Code:
 if (Titlebox.text == @"") {
Both do not work.
The NSLog in the else show up with File Name being nothing
This is from my output thing, debug I think.
Code:
Saving the current sound file. File Name is >  <.
Thanks in advance, you will be helping a lot.
__________________
-----------
Want to see me run to the apple store and back?
~~~Moments Later~~~
Want to see me do it again?
alex5776 is offline   Reply With Quote
Old 05-16-2011, 04:06 PM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

you can't compare a string with == (this compare the pointer on a object)
Quote:
if (!Titlebox.text isEqualToString:@"") {
__________________
dany_dev is offline   Reply With Quote
Old 05-16-2011, 04:07 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

exactly. even if theres nothing in the textbox, its not nil, its @"". use if ([textbox.text isEqualToString:@""])
kapps11 is offline   Reply With Quote
Old 05-16-2011, 04:20 PM   #4 (permalink)
iPhone Developer
 
alex5776's Avatar
 
Join Date: May 2011
Location: Minnesota
Age: 14
Posts: 26
alex5776 is on a distinguished road
Default

I feel a little stupid! I knew that but forgot about it.
Thank you so much!
__________________
-----------
Want to see me run to the apple store and back?
~~~Moments Later~~~
Want to see me do it again?
alex5776 is offline   Reply With Quote
Reply

Bookmarks

Tags
file, if statement, nslog, text field, text field save

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 355
6 members and 349 guests
doffing81, dre, iOS.Lover, Kirkout, MikaelBartlett, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0