Error in function call
I have the following function:
-(void) CalLevels: (NSMutableArray *)rPrices: (NSMutableDictionary *) rLevels: (float) nClose: (float) nHigh: (float) nLow: (float) nOpen {...}
I am calling the above function as follows:
[self CalLevels:rm.rPri开发者_运维问答ces rLevels:rm.rLevels nClose:nCloseD nHigh:nHighD nLow:nLowD nOpen:nOpenD];
I get the warning method not found. Thanks for any help.
You should call it like that:
[self CalLevels:rm.rPrices :rm.rLevels :nCloseD :nHighD :nLowD :nOpenD];
or change the method declaration, since rLevel
and its friends are the internal method name of the variables, not part of the method name.
The correct way is either the one above, or change the method signature:
-(void) CalLevels: (NSMutableArray *)rPrices rLevels: (NSMutableDictionary *) rLevels nClose: (float) nClose nHigh: (float) nHigh nLow: (float) nLow nOpen : (float) nOpen {...}
Your method declaration is busted. You write:
-(void) CalLevels: (NSMutableArray *)rPrices: (NSMutableDictionary *) rLevels: (float) nClose: (float) nHigh: (float) nLow: (float) nOpen
This declares a method named CalLevels::::::
. The rLevels
, nClose
and all that are parsed as the parameters' names. You probably meant to declare one named alLevels:rPrices:rLevels:nClose:nHigh:nLow:nOpen:
. That would look more like this:
- (void)CalLevels:(NSMutableArray *)levels rPrices:(NSMutableDictionary *)rPrices rLevels:(float)rLevels nClose:(float)nClose nHigh:(float)nHigh nLow:(float)nLow nOpen:(float)nOpen
(I'm guessing that nOpen
is meant to be a float.)
What @MByD wrote will work but if you want to adhere to the Naming Conventions you need to rename your method. Right now your method is named CalLevels::::::
and rLevels
, nClose
, etc. are the parameter names that are not part of the name. If you want to follow the Naming Conventions, you need to:
- Start the name with a lowercase letter.
CalLevels...
is wrong,calLevels...
is right. - Use keywords before all arguments.
calLevels::::::
is wrong,calLevels:rPrices:rLevels:nClose:nHigh:nLow:nOpen:
is right.
Resulting in something like this:
-(void)calLevels:(NSMutableArray *)rLevels rPrices:(NSMutableDictionary *)rPrices nClose:(float)nClose nHigh:(float)nHigh nLow:(float)nLow nOpen:(float)nOpen;
精彩评论