簡體   English   中英

Three20-SIGABRT,將TTTableLongTextItem設置為TTStyledText

[英]Three20 - SIGABRT on setting TTTableLongTextItem to 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文檔有點稀疏!

您還將覆蓋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對物業TTTableLongTextItem類型不是TTStyledText ,它只是一個NSString

TTStyledText甚至不是NSString的子類。

您尚未初始化descItem,僅對其進行了分配。 這是基本的可可習語,不需要在每個庫的文檔中都加以說明。

至少,您需要調用-init

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM