1

我的代码如下

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 文档有点稀疏!

4

3 回答 3

3

您还覆盖了 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 对象是什么,所以我不能告诉你很多关于你试图用你好和谷歌网站做什么。

于 2010-03-27T21:42:20.377 回答
2

text属性 onTTTableLongTextItem不是 type ,TTStyledText它只是一个NSString.

TTStyledText甚至不是NSString.

于 2010-03-26T16:01:27.663 回答
0

你还没有初始化 descItem,你只是分配了它。这是基本的 Cocoa 习惯用法,不需要在每个库文档中都详细说明。

至少,您需要调用 -init

于 2010-03-27T21:26:35.773 回答