I have a ‘Member' class inside the project and I'm trying to pass some data from Phone to Watch extension. The error says: Use of unresolved identifier ‘Member'
I tried to create a module ‘MemberKit’ and import it but I still get this eror.
Thanks in advance!
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
if let userInfo = userInfo, request = userInfo["request"] as? String {
if request == "getMembers" {
var members = [Member]()
let temp = Member(nickname: "Tom", phone: "333-111-2222", profilePhoto: "tom.png")
members.append(temp)
reply(["request": NSKeyedArchiver.archivedDataWithRootObject(members)])
return
}
}
reply([:])
}
Make sure that
Memberis declared in a place that your AppDelegate can "see" it.This concept is called "scope" and is crucial to many programming languages, including Swift. Classes declared inside other classes, for example, are not visible outside that class (unless they're given specific access modifiers).
If that solution fails, try this:
Member.swiftin your File Navigator.