Re: Can't cram an NSRange into an NSArray?
Re: Can't cram an NSRange into an NSArray?
- Subject: Re: Can't cram an NSRange into an NSArray?
- From: Phillip Morelock <email@hidden>
- Date: Wed, 19 Jun 2002 12:51:33 -0700
>
With ints I can wrap them in an NSNumber at some unknown cost in
>
performance, but with NSRanges I'm sort of stuck.
You can do the same thing here. My idea comes from a "Java" way of
thinking, so forgive me, but couldn't you just create an "inner class" and
store NSRanges in instances of that class, storing the instances in the
Array?
This has the same style of "unkown cost in performance" that you mention for
NSNumber (wrapping an object around a primitive).
@interface MyRanger : NSObject
{
NSRange theRange;
}
- initWithRange:(NSRange)aRange;
- (NSRange) range;
@end
fillup
On 6/19/02 12:27 PM, "James Winetke" <email@hidden> wrote:
>
Hi. I'm slowly coming up to speed with the slightly twisty relationship
>
between Cocoa and C (at least from a perspective of one who doesn't
>
know C very well yet.) My current problem:
>
>
NSRange myRange;
>
NSMutableArray *myArray;
>
>
myRange = NSMakeRange(0,119);
>
myArray = [[NSMutableArray alloc] init];
>
[myArray addObject: myRange];
>
>
This doesn't work, because of "incompatible type for argument 1" on
>
that last line. It looks to me like I can only put Objective-C objects
>
in NS(Mutable)Arrays; I get similar warnings, though not errors, when I
>
try to put an int in one.
>
>
With ints I can wrap them in an NSNumber at some unknown cost in
>
performance, but with NSRanges I'm sort of stuck. I hope to heck I
>
don't have to resort to stashing pairs of NSNumbers instead of
>
storing nice clean NSRanges. I don't even know how I'd do that
>
cleanly. Arrays of 2-item arrays?
>
>
Thanks for any advice.
>
>
Jim
>
>
_________________________________________________________________
>
Join the worlds largest e-mail service with MSN Hotmail.
>
http://www.hotmail.com
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.