Reputation: 1453
My program looks like this:
-(id)init
{
if ( (self = [super init]) )
{
//TargetWithActions *targetActions= [[TargetWithActions alloc] init];
[self countDownSpeed123];
}
return self;
}
-(void)countDownSpeed123
{
countDownSpeed = 5.0f;
}
@end
warning: 'TargetWithActions' may not respond to '-countDownSpeed123'
I am getting the warning in this way. Where I am wrong in my program. Please explain ? Thank You.
If I need to use the countDownSpeed value in another class, how can I retain the value ? How can I use in the other class? I think retain works for pointer types.
EDIT:
Sorry for my bad coding and negligence. I have did mistakes in my program which are very blunt.
Thanks for answering.
-(void)countDownSpeed123;
)in
interface.Second: I did not include the following in my class where I needed the (countDownSpeed) value.
TargetWithActions *targetActions= [[TargetWithActions alloc] init];
[targetActions countDownSpeed123];
Now, I got what I need.
Thank You.
Upvotes: 1
Views: 1032
Reputation: 79930
In the class where you trying to use
TargetWithActions
, and in TargetWithActions.m
make sure you
have #import
"TargetWithActions.h"
.
In TargetWithActions.h
make sure
in your class declaration
you declared the method -(void)countDownSpeed123;
Sorry I don't understand what are you trying to do with countDownSpeed123
, it does not return anything (void) so I'm not quite sure what you want to retain
. If the method returns simple value like float
or int
you don't have to retain it, it is passed by value - it will be copied.
Upvotes: 3
Reputation: 1453
Sorry for my bad coding and negligence. I have did mistakes in my program which are very blunt. Thanks for answering. First: I did not declare the function ( -(void)countDownSpeed123; )in interface. Second: I did not include the following in my class where I needed the (countDownSpeed) value. TargetWithActions *targetActions= [[TargetWithActions alloc] init]; [targetActions countDownSpeed123]; Now, I got what I need. Thank You.
Upvotes: 0