views:

117

answers:

3

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!

+1  A: 

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

TTStyledText isn't even a subclass of NSString.

pkananen
A: 

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

Jeff Laing
+1  A: 

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.

Alex Gosselin