I have a little problem with calling a method from another class with parameters. I am programming since a few wee开发者_Python百科ks objC.
My aim is to load in another class a method, called:
- (void) openTheCamera:(UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info {
I am calling a method without parameters this way:
[theOtherClassname theOtherMethod];
But how can I call it with parameters? I have tried:
[theOtherClassname openTheCamera:(UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info];
I think that's wrong. How can I do it right?
[theOtherClassname openTheCamera:(UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info];
should work as expected, but the type specifiers are unnecessary and can be even harmful, because you type-cast reader
to UIImagePickerController *
and info
to NSDictionary *
. This is bad, because the compiler won't notify you if your input parameters are of a type that your method does not expect.
You can simply do:
[theOtherClassname openTheCamera:reader didFinishPickingMediaWithInfo:info];
You can use easily protocols:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProtocols.html
Search in this site. you could able to find similar questions...
精彩评论