• 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: Dynamic Instance Variables, is id the answer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic Instance Variables, is id the answer?


  • Subject: Re: Dynamic Instance Variables, is id the answer?
  • From: Robert Martin <email@hidden>
  • Date: Sat, 7 Oct 2006 19:22:06 -0400

http://developer.apple.com/documentation/Cocoa/Reference/ ObjCRuntimeRef/Reference/reference.html

id is the answer if all your ivars are NSObjects. Just create NSObject wrappers for your other types.



On Oct 7, 2006, at 7:12 PM, Jordan Evans wrote:

I need my class's instance variables to be dynamic in the sense that
they could be pointers to any kind of data, for example, pointers to
ints, NSObjects, structs, etc.

Is id the answer?  I hear it's the "generic type", but haven't seen
good examples of it's use.  If so, I'm not sure how to use id (proper,
declaration, initialization, pointing, referencing, etc.).

If not id, then how do I accomplish this dynamic ability for instance
variables to be pointers to any type of data?

@interface DynamoClass : NSObject
{
        id pointerOne;
       id pointerTwo;
       id pointerThree;
}

- (id)initWithString:(NSString *)dataType;

@end

Thanks for any pointers. ;
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40frontiernet.net


This email sent to 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: Dynamic Instance Variables, is id the answer?
      • From: Dominik Pich <email@hidden>
    • Re: Dynamic Instance Variables, is id the answer?
      • From: John Stiles <email@hidden>
References: 
 >Dynamic Instance Variables, is id the answer? (From: "Jordan Evans" <email@hidden>)

  • Prev by Date: Re: Dynamic Instance Variables, is id the answer?
  • Next by Date: Re: Dynamic Instance Variables, is id the answer?
  • Previous by thread: Re: Dynamic Instance Variables, is id the answer?
  • Next by thread: Re: Dynamic Instance Variables, is id the answer?
  • Index(es):
    • Date
    • Thread