一个可以和 Apple Watch 搭配工作的课表 Demo

iOS Apr 25, 2015

Source Code is on Github Class-Timetable

Apple provide an easy way for developers to interact between iPhone and Apple Watch, after adding a new target into your project, you can write the follow code in InterfaceController.m

[WKInterfaceController openParentApplication:@{@"xxxxx": @"xxxxx"} reply:^(NSDictionary *replyInfo, NSError *error) {
        
        if (error) {
            // Do something to deal with error.
            
        } else {
            
            // Insert your code.
        }
        
    }];

Then the iPhone application's delegate will receive a message -- you are expected to call the reply block when you're done to let the system know you've completed any task you needed to execute to complete the response before importing the WatchKit in AppDelegate.m:

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply {
    
    reply(@{@"course": @"error"});
}

Tags

Jie Li

🚘 On-road / 📉 US Stock / 💻 Full Stack Developer / 🎓 Grad Student / ®️ ENTJ