简体   繁体   English

Three20-SIGABRT,将TTTableLongTextItem设置为TTStyledText

[英]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! 非常感谢您的帮助-Three20文档有点稀疏!

You are also overriting styledDesc: 您还将覆盖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. 但是我真的不知道这些TTTableLongTextItem或TTStyledText对象是什么,因此我无法告诉您很多有关Howdy和Google网站的信息。

The text property on TTTableLongTextItem isn't of type TTStyledText , it's just an NSString . text对物业TTTableLongTextItem类型不是TTStyledText ,它只是一个NSString

TTStyledText isn't even a subclass of NSString . TTStyledText甚至不是NSString的子类。

You haven't initialised descItem, you've only alloc'd it. 您尚未初始化descItem,仅对其进行了分配。 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 至少,您需要调用-init

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM