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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:01:26+00:00 2026-05-18T20:01:26+00:00

I have a sample app which i downloaded from net In this i was

  • 0

I have a sample app which i downloaded from net
In this i was unable to understand following code

UILocalNotification *localNotif = [[UILocalNotification alloc] init];

if (localNotif == nil) 
    return;

also

  if (!array1) 
        return;

does this code means if object does not exists then return…..

HELP

  • 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-05-18T20:01:26+00:00Added an answer on May 18, 2026 at 8:01 pm

    In Cocoa, an initialiser will either return an object pointer if the call was successful, or a nil if it was unable to create the object.

    Both cases are checking for the existence of the object. Actually, checking for the existence of a pointer to the object and simply returning if the object does not exist. As an example, here is a common form of initialiser for an object.

    - (id)init  {
        // Call the superclass initialiser first and check that it was successful.
        if (!(self = [super init])) {
            // If the superclass initialiser failed then self will be nil.
            // return a nil because we cannot create this object.
            return nil; // Bail!
        }
        // Do more initialising 
        // If we can initialise the superclass and ourself, return a pointer to ourself
        return self;
    }
    

    However, the snippets you have provided are not enough to tell whether the code is correct. For example, the first example is incorrect if it is part of an initialiser method because it is not returning any kind of object.

    Edit

    From your further examples both of these print hiiiiiiii

    NSArray *arr;
    if(arr) { NSLog(@"hiiiiii");
    

    and

    NSArray *arr = [[NSArray alloc]init];
    if(arr) { NSLog(@"hiiiiii");
    

    In the first case you are declaring arr to be a pointer to an NSArray, but because it hasn’t been initialised this pointer is just a garbage value of random numbers. But it isn’t nil So your if-statement evaluates as true. That doesn’t mean that it is a valid pointer to an NSArray.

    In your second example you declare an NSArray pointer and initialise it. This was successfully initialised so the pointer is not nil and the if-statement evaluates as true. In this case you do have a valid NSArray pointer.

    Declaration is not initialisation!

    Maybe if you explain what it is that you are trying to do we’ll be able to better answer your questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sample app which i downloaded from net In this i was
I have downloaded TableView sample code '4_TableViewCellSubviews' from internet. I am trying to run
I have a simple iphone app that's based on the CrashLanding sample app. So
I have built a simple C#.Net app on a M/C with only .Net FX
I have a simple .NET 2.0 windows form app that runs off of a
When I run this code on my computer with the help of Google App
I have an app which displays 10 images and each image is associated with
I have a simple app that uses an SQL Express 2005 database. When the
I have a simple Google App Engine app, that I wrote using ordinary strings.
Problem 1: I have a simple winforms app and I want to DataBind my

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.