Three20 - 关于设置TTTableLongTextItem到TTStyledText
问题描述:
SIGABRT
我的代码如下Three20 - 关于设置TTTableLongTextItem到TTStyledText
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"
缺少什么我在这里?任何帮助非常感谢 - Three20文档有点稀疏!
答
您还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"];
这里是我的,你真正想要的猜测:
TTTableLongTextItem *descItem = [[[TTTableLongTextItem alloc] init] autorelease];
descItem.text = @"howdy";
,但我真的不知道这些TTTableLongTextItem或TTStyledText对象是什么,所以我不能告诉你很多关于你想用howdy和google网站做什么。
答
text
text
财产TTTableLongTextItem
不是TTStyledText
类型,它只是一个NSString
。
TTStyledText
甚至不是NSString
的子类。
答
你还没有初始化descItem,你只分配它。这是基本的Cocoa成语,它不应该在每个图书馆文件中被阐明。
最起码,你需要调用-init