Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9200453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:46:19+00:00 2026-06-17T22:46:19+00:00

I have a UILabel that is loaded form a text file. Sometimes the text

  • 0

I have a UILabel that is loaded form a text file. Sometimes the text file has something in it and sometimes it is empty. So sometimes the UILabel is blank and sometimes it has text in it.

I want to write an if statement that says if the UILabel is blank do one thing else if it has text in it do another thing.

I have tried

if (self.label.text = NULL)

and

if (self.label.text = @"") 

but it isn’t working correctly.

With the if (self.label.text = @""), I get the if statement to happen but the else statement doesn’t work.

Here is my code

NSString *stuff3 = @"/Stuff";
NSString *titleName = [familyDictionary objectForKey:@"identity"];

NSArray *paths3 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                      NSUserDomainMask, YES);
NSString *documentsDirectory3 = [paths3 objectAtIndex:0];
NSString *stuffPath3 = [documentsDirectory3 stringByAppendingPathComponent:stuff3];
NSString *fullPath3 = [stuffPath3 stringByAppendingPathComponent:titleName];

self.title = [NSString stringWithContentsOfFile:fullPath3  encoding:NSUTF8StringEncoding error:NULL];
NSLog(@"full path 3 >>>%@",fullPath3);

NSString *stuff4 = @"/Stuff/Objects";
NSString *textName3 = [familyDictionary objectForKey:@"identity"];
NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                      NSUserDomainMask, YES);
NSString *documentsDirectory2 = [paths2 objectAtIndex:0];
NSString *stuffPath = [documentsDirectory2 stringByAppendingPathComponent:stuff4];
NSString *fullPath2 = [stuffPath stringByAppendingPathComponent:textName3];
self.wordlabel.text = [NSString stringWithContentsOfFile:fullPath2  encoding:NSUTF8StringEncoding error:NULL];

//Now load the image at fullPath and install it into our image view's image property.
 NSLog(@"full path 3 >>>%@",fullPath2);

if(self.wordlabel.text = @"") 
{
    [textView setTitle:[NSString stringWithContentsOfFile:fullPath3  encoding:NSUTF8StringEncoding error:NULL] forState:UIControlStateNormal] ;
    textView.titleLabel.adjustsFontSizeToFitWidth = TRUE;
}
else
{
    [textView setTitle:[NSString stringWithContentsOfFile:fullPath2  encoding:NSUTF8StringEncoding error:NULL] forState:UIControlStateNormal] ;
    textView.titleLabel.adjustsFontSizeToFitWidth = TRUE;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:46:20+00:00Added an answer on June 17, 2026 at 10:46 pm

    What you are doing is comparing pointers, which doesn’t work with strings. Use this

    if ([self.wordlabel.text isEqualToString:@"thestring"])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple UILabel on that I want to change the text of
I have one UITextField that has a value and one UILabel that has text.
I have a UILabel with right-aligned text that may vary from between three to
I have an application that has a UILabel displaying the current date and time,
I have a UILabel with space for two lines of text. Sometimes, when the
I have a UILabel , and what I want is that when a user
I have a RoundedRectView with a UILabel that holds lines of text of varying
I have a UILabel that I would like to update. It has been added
I have an UILabel that is centered in the screen. I want to place
I have a UILabel that is modified while using my app. I want the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.