Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-10-2010, 12:28 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Location: Paris / France
Age: 38
Posts: 2
Apple92 is on a distinguished road
Default Cannot inherit from NSMutableData

Hi,

I have created a new class, from NSMutableData.

@interface MsgSetGame : NSMutableData {

}

@end

There is no implementation, I just want to used methods from the mother class.

Curiously, I cannot send methods to an object of this class:

const char Buffer[5] = {1, 2, 3, 4, 5};

NSLog(@"Avant création MsgSetGame");
MsgSetGame *myGame = [MsgSetGame alloc];
[myGame initWithLength:40];
NSLog(@"Avant append");
[myGame appendBytes:Buffer length:5];
NSLog(@"Avant release");
[myGame release];

The app crashes with the following message on the console:

2010-01-10 18:51:49.169 BMEngine[21024:207] updateStateMachine: STATE_BIDDING_GAME_UNCOMPLETED
2010-01-10 18:51:49.170 BMEngine[21024:207] Avant création MsgSetGame
2010-01-10 18:51:49.170 BMEngine[21024:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -initWithCapacity: only defined for abstract class. Define -[MsgSetGame initWithCapacity:]!'

Curiously, NSMutableData is not abstract, thus I do not have to implement the inherited methods. Might this be due to the fact that NSMutableData is a custer class?

Regards,
Franz
Apple92 is offline   Reply With Quote
Old 01-10-2010, 04:55 PM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: London
Posts: 226
_sjc_ is on a distinguished road
Default

Technically, both NSData and NSMutableData are abstract. The magic for both is handled by NSCFData, which is the private object bridged to (and indentical with) CFData objects.

That said, I'm not sure how you would go about subclassing it. For other cluster classes (eg. NSString), Apple provides subclassing guidelines listing the atomic methods to provide.

If you don't want to add new ivars to the class, and only want to call existing NSData methods, you could always look at adding a category rather than subclassing.
__________________
SimCap - Simple iPhone and iPad Simulator screen capture
_sjc_ is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 324
12 members and 312 guests
2Apps1Day, akacaj, Domele, Duncan C, GraffitiCircus, michelle, NetGuru, NSString, Paul Slocum, Sloshmonster, soohyun, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,885
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:55 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0