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 オブジェクトが何であるかをよく知らないので、howdy と google の Web サイトで何をしようとしていたかについて多くを語ることはできません.

于 2010-03-27T21:42:20.377 に答える
2

textプロパティTTTableLongTextItemはタイプTTStyledTextではなく、単なるNSString。です。

TTStyledTextのサブクラスでもありませんNSString

于 2010-03-26T16:01:27.663 に答える
0

descItem を初期化しておらず、割り当てただけです。これは Cocoa の基本的なイディオムであり、すべてのライブラリ ドキュメントで詳しく説明する必要はありません。

少なくとも、-init を呼び出す必要があります。

于 2010-03-27T21:26:35.773 に答える