2011-01-31 19 views
0

私はvar current_queryを使用して、アプリケーションにロードするURLを追跡しています。静的型の文字列、つまりcurrent_query = @"hey"でcurrent_queryを指定すると、それは期待されるように動作しますが、私はcurrent_query = [NSString stringWithFormat:@"hey%@",hey2];のような動的な値を使用し始めます。私は奇妙な結果を得ます。NSLog(@"%@",current_query);の場合、私は奇妙な結果を得るでしょう<1002f2c8 c0a8016a 00000000 00000000>何とか私の文字列を変換していますか?何が起きてる?iPhone NSStringの問題

current_queryはすべて@synthesize current_query;

おかげで私の実装ファイルで、その後NSString *current_query;@property (nonatomic, retain) NSString *current_query;としての私のヘッダファイルであると!

+2

hey2とは何ですか?問題を引き起こしているようだ。 – taskinoor

答えて

4

プロパティを設定する代わりに、直接インスタンス変数を設定してみてください:

self.current_query = NSString stringWithFormat:@"hey%@",hey2]; 

(脇:currentQueryは、標準のObj-Cの命名規則で)

-1

最初current_queryを割り当てる十分試し。
NSString current_query = [[NSString alloc] initWithString:@ "hey"];
current_query = [NSString stringWithFormat:@ "hey%@"、hey2];
NSLog(@ "%@"、current_query);

また、hey2がオブジェクトではなく、intのようなプリミティブである場合は、%@は使用できません。適切な文字列トークンを使用する必要があります。