2011-08-25 56 views
0

嘿我編碼使用theos,我想NSString的值顯示在UIAlertView下面的字段內,我將如何去寫呢?這就是:在UIAlertView中調用NSString?

UIAlertView *quickreply = [[UIAlertView alloc] initWithTitle:@"%@" message:@"%@" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"Reply", nil]; 

我已經試過了引號後寫,NSStringID但它給錯誤的整個UIAlertView中,所以IDK的如何,我應該代碼時,我應該用括號以上引號內的引號,還是括號「或者什麼?

請幫助

回答

0
NSString *message = [NSString stringWithFormat:@"%@",myIvar]; 

設置UIAlertView中對消息的NSString

+0

這是什麼MSGambel建議,但我認爲只是設置他們沒有@「」,只是NSString ID會起作用,例如 'initWithTitle:sender message:message'我還沒有能夠測試它 – iGamers

1

用途:

[NSString stringWithFormat:@"%@", theString]; 
如果你想這樣做的

。希望有所幫助!

+0

謝謝你的快速反應的消息,但我發現了一些錯誤與框架標頭由於某種原因 也,我認爲該代碼可能會給我錯誤 Tweak.xm:20:錯誤:預期的標識符之前'['令牌 Tweak.xm:20:錯誤:目標C++混亂年齡參數預計在'['令牌 Tweak.xm:20:error:expected']'之前'['令牌 Tweak.xm:20:錯誤:'alloc'之前預期的主要表達式' 調整。在'alloc'之前xm:20:error:expected']' Tweak.xm:20:error:expected','或';'before'alloc' Tweak.xm:20:error:'message'was not declare在這個範圍內@iGamers:這與你的原始問題完全無關。如果您想要幫助解決這些錯誤,請提出新的問題。 – iGamers

+0

@Josh Caswell:這些錯誤實際上與他建議的代碼有關,它的確與它有關 – iGamers

+0

@iGamers:如果你得到的構建錯誤指的是你鏈接的框架的頭文件反對,那麼這個片段是無關緊要的。 –

2

stringWithFormat是你想要的,試試這個:

NSString *title = [NSString stringWithFormat:@"title is %@", @"my title"]; 
NSString *msg = [NSString stringWithFormat:@"message is %@", @"my message"]; 
UIAlertView *quickreply = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"Reply", nil]; 
+0

我可能應該提到這一點,但字符串已經定義了不同的頭文件 – iGamers

+1

@iGamers,你能提供更多的代碼和問題的描述嗎? –

+0

即時通訊從CoreTelephony框架的CTMessage標頭中拖動字符串,我打電話給我的兩個字符串是發件人和郵件,它將提供傳入的SMS發件人姓名或號碼,以及短信正文,我認爲你的代碼將正常工作,一旦我讓頭部正常工作,但是當我使用theos編譯時,它說頭部給了我錯誤,雖然 – iGamers