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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:29:24+00:00 2026-05-18T08:29:24+00:00

In objective-c is the end result of !variable the same as variable==nil Also I

  • 0

In objective-c is the end result of !variable the same as variable==nil Also I think I read somewhere that iVars are initialized to “nil” (i.e. o) but sadly I can’t seem to find where I spotted it now. If I am correct is this initialization to nil part of declaring an iVar or is it linked to something else like @property?

i.e. do these evaluate the same …

if(!myObject) ...

and

if(myObject == nil) ...

Cheers Gary.

Edited: hopefully for more clarity.

  • 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-18T08:29:25+00:00Added an answer on May 18, 2026 at 8:29 am

    Your question subject and question body appear to be asking different things, so…

    To answer the question subject: No, ! and nil are not at all the same. ! is an operator that returns the logical negation of its operand (that is, !0 returns 1 and ! with anything else returns 0), while nil is a macro for 0.

    To answer the question itself: Yes, !foo and foo == nil give the same result for object variables. And yes, instance variables are initialized to 0. So are static variables and global variables.

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

Sidebar

Related Questions

My end objective is to create an applescript that intelligently inserts a bullet point
I thought an variable in objective-c is just a reference to an object somewhere
(Edit: put possible solution at end) I'm a C/C++ programmer who is learning Objective
I have a protocol in Objective-C, something like this: @protocol Handler +(NSString*) getValue; @end
Objective: In support of a Windows Service that may have multiple instances on a
In Objective-C, what is the actual difference between putting an instance variable in .h
Professionally I am a back-end Java developer, but recently I've been interested in writing
In other languages like (objective-c for example) calling a method on a nil object
Desired end result: user taps a UIImageView and the image changes to another image
Hey I'm trying to learn Objective-C and Cocoa Dev, but I'm having problems with

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.