Throw a request from the AppleWatch to the iPhone.
[WKInterfaceController openParentApplication: userInfo reply:^(NSDictionary*replyInfo, NSError*error){
if(replyInfor){
...
It says
^(NSDictory*replyInfo, NSError* error)
What is doing?
Also, when receiving an AppleWatch request on the iPhone,
-(void) application:(UIApplication*) application handleWatchKitExtensionRequest:(NSDictionary*)userInfo reply:(void(^)(NSDictionary*)) reply{
...
I don't know what **(void(^)(NSDictionary*)) reply** is also doing.
"Maybe it's because I don't understand ""^"" in the first place..."
It doesn't matter if it's a helpful URL.Please tell me who it is.
ios objective-c
The notation that begins with ^
is called a block, which is called a closure or unknown function in other languages, but roughly speaking, it is a language function that allows processing to be stored as an object in a variable or passed as an argument.
↑ In addition to the above official documentation, it is recommended to search for "Objective-C Block" and so on.
Now,
reply:^ (NSDictory* replyInfo, NSError* error)
The part of the is named reply
, passing as an argument a block that takes two arguments: NSDictionary
and NSError
.
In Cocoa, blocks are often used primarily as callbacks for asynchronous methods, which are also used in this method.
The block passed to this reply
will be invoked by the system when the app is called.
This will inform you that the asynchronous method has been executed.
The following delivery methods will be invoked for the called application, so
-(void) application:(UIAapplication*) application
handleWatchKitExtensionRequest: (NSDictionary*) userInfo
reply:(void(^)(NSDictionary*replyInfo)) reply;
For example, you can inform the Watch side of completion (and pass the information at the same time) by filling the NSDictionary
with the required information from the application side and calling the block:
-(void) application:(UIAapplication*) application
handleWatchKitExtensionRequest: (NSDictionary*) userInfo
reply:(void(^)(NSDictionary*replyInfo)) reply
// Do something random...
NSDictionary* replyInfo=@{@"aaa":@"bbb"};
reply(replyInfo);// Invoke block as callback when required action is complete
}
The Watch will then call the block you passed as an argument, where you can see the completion, and if necessary, take the action you gave as a block in advance.
[WKInterfaceController openParentApplication:nil reply:^(NSDictionary*replyInfo, NSError* error){
// This block will be called when the app calls are complete.
NSLog (@"%@", replyInfo); // { "aaa": "bbb"}
}];
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.