initWithObject Confusion
initWithObject Confusion
- Subject: initWithObject Confusion
- From: John Nairn <email@hidden>
- Date: Thu, 8 Apr 2010 14:05:37 -0700
How is this possible?
I wrote code in Snow Leopard to create an array with a single object
using
NSArray *myArray = [ [NSArray alloc] initWithObject:oneObject ] ;
and it worked fine. When it crashed in either Leopard or Tiger, I went
to NSArray documentation and found out that it does not have the
method initWithObject. Once I found that out, it was easy to fix with
the proper
NSArray *myArray = [ [NSArray alloc]
initWithObjects:oneObject ,nil] ;
But, the remaining questions are:
1. Why would the initWithObject: compile in the first place? (perhaps
because one of my custom classes defines an initWithObject: method)
2. Even if it compiles, how can it run in Snow Leopard when there is
no initWithObject: selector for NSArray (or at least according to the
NSArray docmentation there isn't one)?
---------------
John Nairn (1-541-737-4265, FAX:1-541-737-3385)
Professor and Richardson Chair
Web Page: http://www.cof.orst.edu/cof/wse/faculty/Nairn/
FEA/MPM Web Page: http://oregonstate.edu/~nairnj
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden