iCloud data sync and NSManagedObjectContext #119

Closed
wants to merge 3 commits into
from

Projects

None yet

2 participants

@rickerbh
Contributor

Hi,

I've recently been experimenting with the iCloud core data support in MagicalRecord and think I may have found an issue. When syncing data from iCloud back to a core data store on OSX application using MagicalRecord, an error message is popped:

2011-12-29 09:40:44.296 iCloudDataMac[35912:523f] CoreData: Ubiquity: Error importing transaction log: <PFUbiquityTransactionLog: 0x10056c7f0>
transactionLogLocation: <PFUbiquityLocation: 0x10014b670>: /Users/rickerbh/Library/Mobile Documents/XXXXXXXcomglimmerdesigntestiCloudDataMac/TransactionLogs/mobile.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/iCloudData.store/B8QDvwieWRaMLOCloeJolPkbz3jl080sbPBNlbJsM~U=/C38F55E9-83D4-4728-A822-3BD0FFC2D212.1.cdt
transactionNumber: 1
, exception: Can only use -performBlock: on an NSManagedObjectContext that was created with a queue.

It seems that some of the callbacks/notifications don't get triggered when this error arises, although the core data store is correctly updated.

The PRIVATE_QUEUES_ENABLED macro defined in CoreData+MagicalRecord.h only applies to devices that are iOS5 or higher, so the THREAD_ISOLATION_ENABLED macro is what is applied on Mac apps, from what I can see.

I see there are two solutions to this.

  1. Update the macro so PRIVATE_QUEUES_ENABLED works for >=iOS5 devices or Mac apps on >=OSX10.7, or
  2. Update the functions to not use the performBlock facilities, and trigger the notifications another way.

I've updated the macros in my code - although I'm not sure what the side effects (if any) are of using the private queue mechanism on OSX.

I'm happy to create a pull request for my updated macro - just let me know if this is the way you'd like to proceed. If it's user error I'd love to understand what the mistake is.

Cheers,

H.

@magicalpanda

I saw those same messages in my testing as well. While the iCloud support in now included in Magical Record, I haven't had enough time lately go make sure it works with no issues. That said, if you have it working, I'd love to see your solution, and if it fits well with the rest of the code, I'd love to have this problem fixed.

Saul Mora
Founding Panda
saul@magicalpanda.com

On Dec 28, 2011, at 7:15 PM, Hamish Rickerby wrote:

Hi,

I've recently been experimenting with the iCloud core data support in MagicalRecord and think I may have found an issue. When syncing data from iCloud back to a core data store on OSX application using MagicalRecord, an error message is popped:

2011-12-29 09:40:44.296 iCloudDataMac[35912:523f] CoreData: Ubiquity: Error importing transaction log: <PFUbiquityTransactionLog: 0x10056c7f0>
transactionLogLocation: <PFUbiquityLocation: 0x10014b670>: /Users/rickerbh/Library/Mobile Documents/XXXXXXXcomglimmerdesigntestiCloudDataMac/TransactionLogs/mobile.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/iCloudData.store/B8QDvwieWRaMLOCloeJolPkbz3jl080sbPBNlbJsM~U=/C38F55E9-83D4-4728-A822-3BD0FFC2D212.1.cdt
transactionNumber: 1
, exception: Can only use -performBlock: on an NSManagedObjectContext that was created with a queue.

It seems that some of the callbacks/notifications don't get triggered when this error arises, although the core data store is correctly updated.

The PRIVATE_QUEUES_ENABLED macro defined in CoreData+MagicalRecord.h only applies to devices that are iOS5 or higher, so the THREAD_ISOLATION_ENABLED macro is what is applied on Mac apps, from what I can see.

I see there are two solutions to this.

  1. Update the macro so PRIVATE_QUEUES_ENABLED works for >=iOS5 devices or Mac apps on >=OSX10.7, or
  2. Update the functions to not use the performBlock facilities, and trigger the notifications another way.

I've updated the macros in my code - although I'm not sure what the side effects (if any) are of using the private queue mechanism on OSX.

I'm happy to create a pull request for my updated macro - just let me know if this is the way you'd like to proceed. If it's user error I'd love to understand what the mistake is.

Cheers,

H.


Reply to this email directly or view it on GitHub:
#119

rickerbh added some commits Dec 29, 2011
@rickerbh rickerbh Merge branch 'master' of https://github.com/magicalpanda/MagicalRecord
Conflicts:
	NSPersistentStore+ActiveRecord.m
8adca4f
@rickerbh rickerbh Modified macro to avoid "Can only use -performBlock: on an NSManagedO…
…bjectContext that was created with a queue." error on OSX 10.7 Applications using iCloud to sync a core data store. (Issue #119)
ee04f25
@rickerbh
Contributor

I've just realised I've been making changes on my master branch, so my pull request contains all the commits I've ever done. Let me know if you'd like a clean branch to merge. I use github so infrequently I need to keep relearning every time I try to commit something :-(

@magicalpanda

Yeah, wow, that first commit has quite a few things...a branch with just the fixes is much appreciated.

Thanks!

Saul Mora
Founding Panda
saul@magicalpanda.com

On Dec 28, 2011, at 8:35 PM, Hamish Rickerby wrote:

I've just realised I've been making changes on my master branch, so my pull request contains all the commits I've ever done. Let me know if you'd like a clean branch to merge. I use github so infrequently I need to keep relearning every time I try to commit something :-(


Reply to this email directly or view it on GitHub:
#119 (comment)

@rickerbh rickerbh closed this Dec 29, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment