2011-12-13 6 views
0

私はこのようiPhoneで文字列を書式設定または追加する方法は?

NSString *title ; 
- (void)uploadString:(NSString *)string 
{ 


      title =glbl.text; 
      NSMutableString *strRR = [[NSMutableString alloc] initWithString:title]; 
      [strRR appendFormat:@"%@ .html"]; 
      [self.googledocs beginUploadData:dataHtml withTitle:title inFolder:self.adirPath replaceExisting:NO]; 
} 

glblで文字列をフォーマットするには、genesis1.3のようないくつかの値を保持していると私はgenesis1.3.html. stRR is holding the value genesis1.3 and I want to append STRR with .html`ある.htmlと、この文字列の書式を設定するラベルです。これを行う方法?私は上記のコードでいくつかのエラーがあります。 ありがとうございます。

+0

それはどのようなエラーあなたは手に入れている? – Kevin

+0

@Kevinプログラムが受信した信号EXC悪いここで私はエラーが発生します[strRR appendFormat:@ "%@ .html"]; – ICoder

+0

さらに進んでいく前に、基本的なNSString関数について学ぶ必要があります。 [NSString spec](http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html)を読んでください。 –

答えて

3
NSString * stRR = [NSString stringWithFormat:@"%@.html", title]; 
+0

私は[strRR appendFormat:@ "%@ .html"]の代わりに移動コードを入れます。この権利? – ICoder

+0

(軽微な詳細 - 私は彼が本当に ".stRR"を望んでいるとは思っていませんが、それは文章を終える期間と次の文章を始める変数名です) –

+0

@PeterPeiGuoそれはうまく動作します。 title.htmlの前にELToch_Bibleのような静的な文字列を置くことはgneiss1.3.htmlのようにELToch_Bible genesis1.3.html.thanks – ICoder

1

私はあなたが[strRR appendFormat:@"%@ .html"];

形式を満たすために何を提供していないので、あなたが問題を抱えていることを推測している(そして、それはstringByAppendingFormat:でなければなりません。)

関連する問題