I just realized valueWithPoint is not available on the iPhone SDK and,
I can't understand why, it can't be discussed here. Both things of
course suck! :)

Thanks a lot, chr



On Tue, Sep 16, 2008 at 11:24 AM, Graham Cox <[EMAIL PROTECTED]> wrote:
>
> On 16 Sep 2008, at 7:18 pm, Christian Giordano wrote:
>
>> ... forKey:[[NSNumber alloc] initWithInt:BAND_RED]];
>>
>> Not a really elegant solution but I can understand that those
>> containers require pointers.
>>
>> Now I need to create a NSMutableArray of CGPoint, how can I make it
>> became a pointer?
>>
>> ... addObject:CGPointMake(x,y)];
>>
>> returns indeed "error: incopatible type for argument 1 of 'addObject:'
>>
>> Is there a more elegant way to use structs as key or as mutable
>> container's items?
>
>
> [NSValue valueWithPoint:NSMakePoint( x, y )];
>
> this wraps a NSPoint with an object that can be stored in a dictionary.
> CGPoints and NSPoints have the same structure so you can cast one to
> t'other.
>
> For keys, the usual approach if your keys are simply constants is to define
> them as literal strings:
>
> // .h
>
> extern NSString* BAND_RED;
>
>
> // .m
>
> NSString* BAND_RED = @"BAND_RED";
>
> A literal string is directly usable as an object. If the key needs to change
> dynamically (rare) then strings are still a good bet, but the "wrap in a
> NSValue" approach is acceptable I guess.
>
>
> hth,
>
> Graham
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to