开发者

Three20 - SIGABRT on setting TTTableLongTextItem to TTStyledText

开发者 https://www.devze.com 2022-12-24 02:01 出处:网络
My code is as follows TTTableLongTextItem *descItem = [[TTTableLongTextItem alloc] autorelease]; TTStyledText *styledDesc = [[TTStyledText alloc] autorelease];

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 s开发者_如何转开发parse!


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.


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

TTStyledText isn't even a subclass of NSString.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号