0

我已经按照教程 在类之间传递数据

做到了,并且工作正常,但我真的需要将一些字符串值(日期)发送到另一个视图,(我知道这很简单,但我对此很陌生!),

  • 所以我的问题是我需要将这个字符串(日期)发送到另一个视图,字符串没问题,但我似乎(还)不知道如何构造函数,

我没有收到任何警告,但应用程序中断,

    - (void)calendarView:(KLCalendarView *)calendarView tappedTile:(KLTile *)aTile{
NSLog(@"Date Selected is %@",[aTile date]);

string1 = [[aTile date] description];
dateis.text = string1; //label to check string is working

NSLog(@"ahi va! %@", string1);

NSString *cucux = dateis.text;

CroTime *croco = [CroTime alloc];
croco.string1 = cucux;
[self.view addSubview:croco.view];

NSLog(@"croco = %@", cucux);

 }

控制台消息

   Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CroTime setString1:]: unrecognized selector sent to instance 0x5e2e1e0'

非常感谢!!

4

1 回答 1

1

setString1 是一个 setter 方法,它在您设置属性值时调用。因此,从您的错误来看,这看起来像是您在 CroTime 类中创建了一个属性 string1,但您没有合成它。

这种情况只在这种情况下发生。因此请确保在制作属性时将其合成到 .m 文件中。

于 2011-02-24T05:12:54.650 回答