gavinblair
gavinblair

Reputation: 386

Three20 - SIGABRT on setting TTTableLongTextItem to TTStyledText

My code is as follows

TTTableLongTextItem *descItem = [[TTTableLongTextItem alloc] autorelease];
TTStyledText *styledDesc = [[TTStyledText alloc] autorelease];
styledDesc = [TTStyledText textWithURLs:@"howdy http://www.google.com"];

//this line causes the SIGABRT:
descItem.text = styledDesc;
//I also get a warning on this line that says "warning: passing argument 1 of 'setText:' from distinct Objective-C type"

What am I missing here? Any help is muchly appreciated - Three20 documentation is a little sparse!

Upvotes: 1

Views: 378

Answers (3)

Alex Gosselin
Alex Gosselin

Reputation: 2930

You are also overriting styledDesc:

declare a vairable styledDesc, and assign a TTStyledText instance that is autoreleased (but not initialized, should be [[[TTStyledText alloc] init] autorelease];
TTStyledText *styledDesc = [[TTStyledText alloc] autorelease];
//create a new autoreleased TTStyledText instance via the textWithURLS: member function, and assign it to styledDesc. styledDesc abandons the pointer to the one you made with alloc.
styledDesc = [TTStyledText textWithURLs:@"howdy http://www.google.com"];

Here's my guess of what you really want:

TTTableLongTextItem *descItem = [[[TTTableLongTextItem alloc] init] autorelease];
descItem.text = @"howdy";

but I don't really know what these TTTableLongTextItem or TTStyledText objects are so I can't tell you much about what you were trying to do with the howdy and google website.

Upvotes: 3

Jeff Laing
Jeff Laing

Reputation: 275

You haven't initialised descItem, you've only alloc'd it. This is basic Cocoa idiom, it shouldn't need to be spelled out in every libraries documentation.

At the very least, you need to call -init

Upvotes: 0

pkananen
pkananen

Reputation: 1325

The text property on TTTableLongTextItem isn't of type TTStyledText, it's just an NSString.

TTStyledText isn't even a subclass of NSString.

Upvotes: 2

Related Questions