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 7927925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:35:01+00:00 2026-06-03T19:35:01+00:00

I am really new to Xcode and iPhone development. I have written a function

  • 0

I am really new to Xcode and iPhone development. I have written a function in my appDelegate.m file called getISlogged;. It goes something like this:

- (BOOL) getISlogged {
    NSUserDefaults *usenow = [NSUserDefaults standardUserDefaults];
    NSNumber *islog = nil;
    if(usenow){
        islog = [usenow objectForKey:@"is_log"]; // should equal 1 or 0...
    }

    UIAlertView * alert1 = [[UIAlertView alloc] initWithTitle:@"works" message:@"test1" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles: nil];
    [alert1 show];
    if (islog == [NSNumber numberWithInt:(1)]) {
       return YES;
    } else {
        return NO;
    }
}

Ok, now i call it from my viewController.m like so:

SWGAppDelegate *appDelegate = (SWGAppDelegate *)[[UIApplication sharedApplication]delegate];
NSString *islog = @"no";
if(appDelegate.getISlogged){
   islog=@"yes";
}

Now when I run it I always get Thread 1: breakpoint 2.1 and i have no idea what do do with that. I have tried removing all the code and leaving just return YES; in the function and I still get the same error =\

Any help or tips would help thank you.

  • 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-03T19:35:03+00:00Added an answer on June 3, 2026 at 7:35 pm

    Just simply return the boolValue of the NSNumber instance, rather than extracting its integer value, comparing it to 1, and returning YES or NO based on that, e.g. your entire method could be reduced to:

    - (BOOL) getISlogged {
        return [[[NSUserDefaults standardUserDefaults] objectForKey:@"is_log"] boolValue];
    }
    

    If the key does not exist in the user defaults, the result of this method will be NO.

    Another “code-smell” is that you are assigning Boolean values to a string (with @"yes" and @"no" being assigned to islog). There is nothing wrong with that if you simply plan to write the string somewhere, e.g. to a log, but if you are planning on using this variable to determine whether or not to write to a log, then you should instead make it a BOOL. Strings are for storing text, that’s it.

    Lastly, remember that in Objective-C the == operator compares object identity (that is, it confirms that two references point to the same object), it doesn’t compare object equality. You can use the built-in isEqual: methods for NSNumber or “extract” the boxed value and compare against another unboxed value, e.g. either of this will do the trick:

    if ([islog isEqualToNumber:[NSNumber numberWithInt:1]])
        // do something
    
    // or
    
    if ([islog intValue] == 1)
        // do something
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to iPhone development and Xcode, so this might be really obvious. I
I have an other problem with Xcode 4. I really like the new IDE
I just started doing some reading (new to xcode/iphone development) into web services and
I have created a new iPhone project in Xcode 4 and added some files
Hi I am new to Xcode development for the iPhone and am stuck on
Hey there, I'm a designer thats really new to programming with xcode or Objective-C
im really new to linq-to-SQL so this may sound like a really dumb question,
I'm really new to Python. I'm trying to import a third party module called
I want to move to the new XCode 3.2.3 GM Seed build for development,
I have an existing working iPhone project inside XCode 4.2. I localized an image

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.