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

  • Home
  • SEARCH
  • 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 8742685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:32:34+00:00 2026-06-13T11:32:34+00:00

I made Sender class and sender object: Sender *sender = [[Sender alloc] init]; Then,

  • 0

I made Sender class and sender object:

Sender *sender = [[Sender alloc] init];

Then, I wrote test:

// should success
[sender upload:[UIImage imageNamed:@"test2.jpg"] withName:@"test2.jpg"];
// should fail
[sender upload:nil withName:@"test2.jpg"];

Then, I wrote nil check code:

- (void)upload:(UIImage *)image withName:(NSString *)name
{
    if ([image isEqual:nil]) {
        ...
    }
    ...
}

But nil check is ignored.
How can I check whether the image parameter is nil or not?
Thank you for your kindness.

  • 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-13T11:32:35+00:00Added an answer on June 13, 2026 at 11:32 am

    Short answer, replace [image isEqual:nil] with image == nil.

    Long answer, when you write:

    [image isEqual:nil]
    

    you are asking for the message isEqual: to be sent to the object whose reference is stored in the variable image.

    However you don’t wish to send a message to an object, you wish to determine whether the variable image contains a reference to an object or not. To do this you need to compare the value of your reference with the “no reference” value – which is written nil. The value comparison operator in Objective-C (and C et al) is == so you need to test:

    image == nil
    

    Now you might ask why did the code you have execute without error, just not producing the result you expected, given that there is no object to send a message to? Objective-C supports sending messages to “no object”, aka nil, and returns the “zero” value for the result type, i.e. 0, nil etc. When converted to a boolean value, as in your if statement, a “zero” value produces NO.

    HTH

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

Sidebar

Related Questions

I just wrote some code. It has my own custom made class. In that
I have made the following code in a c# project: private void RandAddButton_Click(object sender,
i made an .xib file and added my buttons and labels. Then I created
I have made the following class to avoid the repetition if else code ,
I'm trying to do something along these lines: private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
I made a custom button by inheriting the Button class. When I double click
I made a custom Class named MedinetParse that parses a webrequest. The parsed data
I'm trying to create some custom FaultException . I've made a DataContract class called
So I have a class made specifically for holding an event handling method which
I've made myself a class that reads RSS feeds and returns them to 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.