Re: structs in Mutable containers

2008-09-16 Thread Phil
On Tue, Sep 16, 2008 at 9:18 PM, Christian Giordano [EMAIL PROTECTED] wrote: Hi guys, I'm finding myself trying to add to mutable containers like NSMutableDictionary or NSMutableArray instead of NSObjects subclasses, just structs. For instance in a NSMutableDictionary the key was an integer

Re: structs in Mutable containers

2008-09-16 Thread Christian Giordano
I didn't think about NSValue, thanks. Do you mean valueWithPointer? Cheers, chr On Tue, Sep 16, 2008 at 11:00 AM, Phil [EMAIL PROTECTED] wrote: On Tue, Sep 16, 2008 at 9:18 PM, Christian Giordano [EMAIL PROTECTED] wrote: Hi guys, I'm finding myself trying to add to mutable containers like

Re: structs in Mutable containers

2008-09-16 Thread Graham Cox
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? ...

Re: structs in Mutable containers

2008-09-16 Thread Christian Giordano
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

Re: structs in Mutable containers

2008-09-16 Thread Roland King
well can you manage the lifetime of the CGPoints well enough to use valueWithPointer: which, if I read it correctly, doesn't free the pointer when it's done? Or just write your own NSObject derivation you can pass a CGPoint to, by value and have it copied, or as a pointer, but which it

Re: structs in Mutable containers

2008-09-16 Thread Phil
On Tue, Sep 16, 2008 at 10:46 PM, Christian Giordano [EMAIL PROTECTED] wrote: I just realized valueWithPoint is not available on the iPhone SDK It's just a convenience method for something like: [NSValue valueWithBytes:somePoint objCType:@encode(NSPoint)] You can implement this yourself in a

Re: structs in Mutable containers

2008-09-16 Thread Christian Giordano
Yep, this should work as well. Thanks, chr On Tue, Sep 16, 2008 at 1:41 PM, Phil [EMAIL PROTECTED] wrote: On Tue, Sep 16, 2008 at 10:46 PM, Christian Giordano [EMAIL PROTECTED] wrote: I just realized valueWithPoint is not available on the iPhone SDK It's just a convenience method for

Re: structs in Mutable containers

2008-09-16 Thread Phil
On Wed, Sep 17, 2008 at 12:41 AM, Phil [EMAIL PROTECTED] wrote: [NSValue valueWithBytes:somePoint objCType:@encode(NSPoint)] Should be: NSPoint somePoint = NSMakePoint(x,y); [NSValue valueWithBytes:somePoint objCType:@encode(NSPoint)]; Phil ___

Re: structs in Mutable containers

2008-09-16 Thread Mike Abdullah
What's wrong with +[NSValue valueWithCGPoint:CGPointMake(x, y)] ? On 16 Sep 2008, at 13:41, Phil wrote: On Tue, Sep 16, 2008 at 10:46 PM, Christian Giordano [EMAIL PROTECTED] wrote: I just realized valueWithPoint is not available on the iPhone SDK It's just a convenience method for

Re: structs in Mutable containers

2008-09-16 Thread Sean McBride
On 9/16/08 8:24 PM, Graham Cox said: CGPoints and NSPoints have the same structure so you can cast one to t'other. You shouldn't really. You should use NSPointFromCGPoint/ NSPointToCGPoint. Their implementation is in NSGeometry.h and is not a simple cast. NSPoint and CGPoint may be the same

Re: structs in Mutable containers

2008-09-16 Thread Clark Cox
On Tue, Sep 16, 2008 at 7:49 AM, Sean McBride [EMAIL PROTECTED] wrote: On 9/16/08 8:24 PM, Graham Cox said: CGPoints and NSPoints have the same structure so you can cast one to t'other. You shouldn't really. You should use NSPointFromCGPoint/ NSPointToCGPoint. Their implementation is in

Re: structs in Mutable containers

2008-09-16 Thread Sean McBride
On 9/16/08 9:45 AM, Clark Cox said: NSPoint and CGPoint may be the same now, but they may not always be. (Consider that NSAffineTransformStruct and vImage_AffineTransform were the same, but the former changed from float to CGFloat and the latter stayed float, even in 64 bit.) Also, they are