Re: Trying to understand -- please help...
Re: Trying to understand -- please help...
- Subject: Re: Trying to understand -- please help...
- From: "Shawn Erickson" <email@hidden>
- Date: Wed, 21 May 2008 11:54:50 -0700
On Wed, May 21, 2008 at 11:35 AM, Johnny Lundy <email@hidden> wrote:
> Here's why the OP was not aware of the behavior of an NSArray class method:
> Here's the verbatim documentation for +arrayWithObjects:
>
>
>> arrayWithObjects:
>> Creates and returns an array containing the objects in the argument list.
>>
>> + (id)arrayWithObjects:(id)firstObj, ...
>>
>> ParametersfirstObj, ...
>> A comma-separated list of objects ending with nil.
>>
>> Return Value
>> An array containing the objects in the argument list.
>>
>> Discussion
>> This code example creates an array containing three different types of
>> element:
>>
>> NSArray *myArray;
>> NSDate *aDate = [NSDate distantFuture];
>> NSValue *aValue = [NSNumber numberWithInt:5];
>> NSString *aString = @"a string";
>> myArray = [NSArray arrayWithObjects:aDate, aValue, aString, nil];
>> Availability
>> • Available in Mac OS X v10.0 and later.
>> See Also
>> • + array
>> • + arrayWithObject:
>> Declared InNSArray.h
>
> See? Not a word about autoreleasing anything, or having to retain the
> returned array. Nada.
The "Cocoa" memory contract is almost universally applied to all of
Cocoa and related frameworks. So no point exists in stating that
something follows the expected memory contract (only the exceptions
are documented).
It is expected that you have at least looked at the getting started
documentation before you attempt to dive much into anything else. You
would quickly run across the following...
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_1.html#//apple_ref/doc/uid/TP40002974-CH4>
Also note any verbiage talking about retain / autorelease, etc isn't
(really) relevant if the garbage collection is being used.
-Shawn
_______________________________________________
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