But i'm getting errors when declaring like this.
@implementation data
-(void)SwapEndian:(uint8_t*)pData withBOOLValue:(bool)bIsAlreadyLittleEndian
{
data* datas = [data alloc];
[datas swapEndians:(uint8_t)&pData[nIndex] withSize:(sizeof(uint32_t));
}
-(void)swapEndians:(uint8_t*)pData withnByteSize:(int const)nByteSize
{
NSLog(@"swapEndians!!");
}
@end
How to call a function from other function i开发者_如何转开发nside the same class?
You can use self keyword to achieve this.
[self yourFunctionName];
First things first:
data* datas = [data alloc]; // Where is your init? Don't use un-initialized objects! [datas swapEndians:(uint8_t)&pData[nIndex] withSize:(sizeof(uint32_t));
Second thing:
If the method you are trying to call is the second one from you code, you have a typo in the selector!
That line should read:
[datas swapEndians:&pData[nIndex] withnByteSize:sizeof(uint32_t)];
Third thing:
You send messages to yourself by using self
.
First of all class name should start with capital letter, here is I think you are tying to do
@implementation Data //changed it just naming convention
-(void)swapEndian:(uint8_t*)pData withBOOLValue:(bool)bIsAlreadyLittleEndian
{
[self swapEndians:(uint8_t)&pData[nIndex] withSize:(sizeof(uint32_t));
}
-(void)swapEndians:(uint8_t*)pData withnByteSize:(int const)nByteSize
{
NSLog(@"swapEndians!!");
}
@end
精彩评论