NSString のプロパティを作成し、クラスの関数で初期化しました。
今、私は NSLog() 別の関数を使用して、この文字列の内容を表示しています。
入力したものを取得する代わりに、奇妙な文字列を取得しています。
私のコードリストは次のとおりです。
@property(nonatomic, retain) NSString *stringWithProperty;
現在実装中:
- (IBAction)FirstButtonPressed:(id)sender
{
NSString *x= [labelForSecondLine.text substringWithRange:NSMakeRange(0, 2)];
NSString *y= [labelForSecondLine.text substringWithRange:NSMakeRange(3, 2)];
NSString *z= [labelForSecondLine.text substringWithRange:NSMakeRange(5, 2)];
stringWithProperty=[NSString stringWithFormat:@"%@-%@-20%@",x,y,z];
}
- (IBAction)secondButtonPressed:(id)sender
{
NSLog(@"%@",stringWithProperty);
}
最初に押した後に2番目のボタンを押すと、次の出力が得られます。
<UIButtonContent: 0x71533b0 Title = (null), AttributedTitle = (null), Image = (null), Background = (null), TitleColor = UIDeviceWhiteColorSpace 1 1, ShadowColor = UIDeviceWhiteColorSpace 0 0.5>
私やこのコードで何がうまくいかないのか、誰か教えてもらえますか?