• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Check the class of a variable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check the class of a variable?


  • Subject: Re: Check the class of a variable?
  • From: Charlton Wilbur <email@hidden>
  • Date: Thu, 6 Apr 2006 09:42:04 -0400


On Apr 6, 2006, at 9:24 AM, d2kagw wrote:

Hey there all..

Just wondering if theres a easy way of checking the class of a variable...
I've gotten this far:


if ( [[theChildren objectForKey:@"data"]  class] == @"NSCFArray" )
{
	// do something
}

Look for documentation for +class and -isKindOfClass:. You want something like:


if ([[theChildren objectForKey: @"data"] isKindOfClass: [NSArray class]])

(It's also a bad idea to refer to classes that aren't explicilty documented and public. Apple could change the implementation of NSArray in 10.4.7 so that it doesn't use NSCFArray, or so that it uses NSCFArray differently. Relying on undocumented behavior *will* burn you sooner or later, and when it does, it will be painful.)

And you've asked a couple basic questions - you would probably benefit considerably (and try the patience of people who are helping you considerably less in the long run) by getting your hands on a good basic book on Cocoa programming, such as Aaron Hillegass's _Cocoa Programming for Macintosh OS X_. You don't want to use up your welcome by asking a lot basic questions that you can easily find answers for; because if you do, when you get to difficult questions where you actually need the resources of the list, people will be tired of answering your questions.

Charlton


-- Charlton Wilbur email@hidden email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Check the class of a variable?
      • From: James Bucanek <email@hidden>
References: 
 >Check the class of a variable? (From: d2kagw <email@hidden>)

  • Prev by Date: Re: Check the class of a variable?
  • Next by Date: Re: NSTableViews with NSSliderCells
  • Previous by thread: Re: Check the class of a variable?
  • Next by thread: Re: Check the class of a variable?
  • Index(es):
    • Date
    • Thread