PhilipsHue / PhilipsHueSDK-iOS-OSX

The Software Development Kit for Philips Hue on iOS and OS X (beta)
579 stars 169 forks source link

[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (PHLight)' #72

Closed 474404603 closed 9 years ago

474404603 commented 9 years ago

Hello, when i try to use this command line [self.phHueSDK setBridgeToUseWithIpAddress:ipAddress macAddress:macAddress]; ...... it gives me this below error : * Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '* -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (PHLight)' ..... could you please verify this problem? is there any solution? thank you..........

lightbow commented 9 years ago

I get the same thing when calling [PHBridgeResourcesReader readBridgeResourcesCache].lights. I suspect they didn't account for a file format change in the bridge resources cache, and we are seeing the problem when our corresponding apps hit the cache for the first time.

I suspect the temporary workaround will be to trash your app / reset your simulator and rebuild (so the cache file is cleared) but that's not a real solution. I'd have thousands of users complaining if I released a software update that required them to trash the app and reinstall (or had my app clear the cache file, which would probably force the user to push link again)

pverh commented 9 years ago

It looks like lightbow is right, and it is caused by a bridge cache written to disk with the old SDK cannot be read by the new SDK. I don't think we can solve this issue on the short term.

Letting the app clear the cache on first start of the app with the new SDK is the only user-friendly way in this case. The result will be that app should at least configure the SDK to use the bridge again (with setBridgeToUseWithIpAddress:ipAddress ). The user shouldn't be forced to push link again this way, as his generated device ID is stored somewhere else and not in the cache.

pverh commented 9 years ago

All the other suggestions like reinstalling the app would need a new push link to work, and you don't want that for your users