Re: NSData
Re: NSData
- Subject: Re: NSData
- From: email@hidden
- Date: Thu, 12 Dec 2002 17:36:02 -0800 (PST)
Hello!
Thanks for your reply! And thanks to the other persons
who also replied.
>
i dont think, you really need to subcalss NSData.
How can you know?
>
Usually it s just fine to make up a new, NSObject
based
>
class and USE AN INSTANCE of NSData (or whatever
>
other class you think is suitable). So, you can just
>
create your class in IB as you are used to.
So basically what you tell me is this:
---------------------------
@interface MyDataObject : NSObject {
NSData * mData;
-- All added members here --
}
--- all added methods here ---
@end
---------------------------
Consequence of what, if I want for instance to access
some data chunk inside of my data, I would have to do
for instance:
---------------------------
@implementation MyDataObject
--- among other methods: ---
- (NSData *)subdataWithRange:(NSRange)range {
return [mData subdataWithRange:range];
}
--- etc ---
@end
---------------------------
or something like this.
This is apparently very weird, because I have then to
reimplement likewise all the methods that I would get
"for free" by inheritance. At least, that's what I would
get in C++. Probably I am missing something...
I thought I can simply write:
---------------------------
@interface MyDataObject : NSData {
-- All added members here --
}
--- all added methods here ---
---------------------------
and then since my object *IS* an NSData, I can call
directly, without having to write the method in
MyDataObject implementation:
[MyDataObjectInstance subdataWithRange:range];
Doesn't it work like this?
>
Still, you might want to do it the other way round-
>
I think most people do it like this: create your class
>
"by hand" as you put it, in PB and then drag the .h
>
file into IB. IB will automatically parse it and put
it
>
in the class list.
That's good to know. I'll try this.
>
From there, you can then instantiate the class, if
>
you really need to (I dont even think you need to do
>
that for your plain data-class).
Just curious: how can you say that I don't need it?
Please take no offense of this, I got another reply
saying that I shouldn't subclass NData. I would like to
understand the logic behind it. I guess there must be
some very specific reason (e.g. it cannot work because
..., it is highly inefficient because ... and ..., or
some
reason like this).
>
If you defined IBActions and IBOutlets, IB will
recognize
>
those and you can do all connecting stuff visually, by
>
drag-n-drop, in IB.
Thanks!
Pascal
_______________________________________________
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.