sbonami / PFIncrementalStore

Offline Parse with Core Data Persistence, an NSIncrementalStore subclass.
http://sbonami.github.io/PFIncrementalStore/
MIT License
97 stars 15 forks source link

Does this sync between two separate users? #12

Closed Spokane-Dude closed 10 years ago

Spokane-Dude commented 10 years ago

I'm looking for a replacement for FTASync... will this do it?

sbonami commented 10 years ago

Can you provide a little more detail as to what you're looking to do? Is this syncing a Parse user with a CoreData user? Is this syncing one Parse user with another?

Spokane-Dude commented 10 years ago

Never mind... after reading more, I see the answer is NO.

Spokane-Dude commented 10 years ago

Hi Scott... yes, it's an iPad app, using Core Data and I want to be able to have multiple unique physical users be able to use a particular Core Data store. So, sync'ing is the only way to accomplish that.

Regards, Rolf

Scott BonAmi mailto:notifications@github.com December 16, 2013 at 10:13 AM

Can you provide a little more detail as to what you're looking to do? Is this syncing a Parse user with a CoreData user? Is this syncing one Parse user with another?

— Reply to this email directly or view it on GitHub https://github.com/sbonami/PFIncrementalStore/issues/12#issuecomment-30684834.

sbonami commented 10 years ago

Rolf, I think this has more to do with how you query the data and less to do with syncing it.

There's several ways you could achieve this:

Let me know if either of these interest you, although I will add that they are falling outside the scope of PFIncrementalStore. Your questions would probably benefit from being posted on StackOverflow.

Spokane-Dude commented 10 years ago

Hi Scott... this app is a appointment booking app... as such, it needs to sync with one Core Data store (SQLite) so when one user makes an appointment, other users will see that a particular time slot has been taken or not, and act accordingly.

I have some code I was given that will accomplish this, but needs work and testing. Was just hoping to get something "out of the box" so to speak... :D

R

Scott BonAmi mailto:notifications@github.com December 16, 2013 at 11:00 AM

Rolf, I think this has more to do with how you query the data and less to do with syncing it.

There's several ways you could achieve this:

  • multiple databases backed dynamically named/accessed based on the user's id (and subsequently a user's permissions)
  • utilizing Parse's ACL for permissions (I haven't personally done this and I don't yet have this functionality built into /PFIncrementalStore/)
  • add a object-user relationship and only query objects attached to that user

Let me know if either of these interest you, although I will add that they are falling outside the scope of /PFIncrementalStore/. Your questions would probably benefit from being posted on StackOverflow http://stackoverflow.com/questions/ask.

— Reply to this email directly or view it on GitHub https://github.com/sbonami/PFIncrementalStore/issues/12#issuecomment-30689151.

sbonami commented 10 years ago

"Out of the box" is precisely why I started PFIncrementalStore :) This project still has a few more changes that need to happen before I list it on cocoapods, and even then I would consider it a development-only project until further testing can be done. That being said, I'd do the following (these are rough instructions off the top of my head):

    User *currentUser = <# current user #>;
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"user = %@", currentUser];

    NSError *error = nil;
    NSManagedObjectContext *context = <#Managed Object Context #>;
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"Appointment"];
    [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"appointmentUser = %@", currentUser]];
    NSArray *results = [context executeFetchRequest:fetchRequest error:&error];

NOTE: PFIncrementalStore adds additional fields necessary to keep everything synced. Steps for migrating your schema should be taken or your app may crash.

NOTE: PFIncrementalStore will be submitted to cocoapods soon at which time the git declaration can be dropped from the Podfile.

Spokane-Dude commented 10 years ago

It sounds like you are saying that I can do Core Data sync'ing between one Core Data store and multiple concurrent users? Is that correct? If so, I'm onboard! Now there might be one glitch: I use MagicalRecord for all of the Core Data calls... is that going to be a problem? (it doesn't look like to me, but then again, I didn't write your code! ) :D

R

sbonami commented 10 years ago

If I understand everything as you've described, then yes I am saying that you can sync Core Data with multiple users. As far as MagicalRecord goes, it's a layer that sits on top of CoreData and as such shouldn't be affected by PFIncrementalStore. I've not personally used MagicalRecord so give it a shot and report back on any issues you may run into. Check out this StackOverflow q&a about connecting another incremental store with MagicalRecord.

Spokane-Dude commented 10 years ago

I'll get started on it tomorrow... Don't know where you are, but I'm in Spokane, WA, and it's getting late! :D

Spokane-Dude commented 10 years ago

I don't know anything about CocoaPods, but this line doesn't seem right:

pod 'PFIncrementalStore, git: 'https://github.com/sbonami/PFIncrementalStore.git'

Unbalanced single quote and there is no 'install' command... am I correct? Anyway, it can't find the specificaiton for PFIncrementalStore. :-{

sbonami commented 10 years ago

I did say they were rough instructions :wink: I've updated the instructions to fix the unbalanced quote and clarify what I meant. Since I have not completed a 0.0.1 release to my satisfaction this library and its specification has not yet been pushed to Cocoapods, thus you must explicitly declare the git location.

Spokane-Dude commented 10 years ago

You don't need 'install'?

R

Scott BonAmi mailto:notifications@github.com December 16, 2013 at 8:58 PM

I did say they were rough instructions :wink: I've updated the instructions to fix the unbalanced quote and clarify what I meant. Since I have not completed a |0.0.1| release to my satisfaction this library and its specification has not yet been pushed to Cocoapods, thus you must explicitly declare the git location.

— Reply to this email directly or view it on GitHub https://github.com/sbonami/PFIncrementalStore/issues/12#issuecomment-30726352.

sbonami commented 10 years ago

Cocoapods has an awesome Getting Started guide (http://beta.cocoapods.org/#get_started) to walk you through getting everything set up. After creating a Podfile and adding the line mentioned above, you will run pod install to generate a Pods directory, workspace, etc.

Spokane-Dude commented 10 years ago

How do I get your updates to PFIncrementalStore?

sbonami commented 10 years ago

Keep an eye on the repo. As changes are made, you can just call pod from the same directory as your Podfile to fetch the latest updates from GitHub.

Spokane-Dude commented 10 years ago

Here's my two cents worth -- when you get a chance, I think you need to elaborate on the instructions for including PFIncrementalStore in the developer's app (where, how, etc)... I'm lost! :-{

From what I've read, once I have this set up and registered, apparently none of my calls to MR for Core Data change... it's all handled under the covers, so to speak. Am I on the right track?

Sorry for the lame question... to give you a little background: I've been programming since the 1960's on mainframes, mid-range, PCs and now iApps... I'm 71 years old! I do this as a sort of hobby... keeps my mind active!

R

Scott BonAmi mailto:notifications@github.com December 17, 2013 at 6:31 AM

Keep an eye on the repo. As changes are made, you can just call |pod| from the same directory as your |Podfile| to fetch the latest updates from GitHub.

— Reply to this email directly or view it on GitHub https://github.com/sbonami/PFIncrementalStore/issues/12#issuecomment-30754862.

Spokane-Dude commented 10 years ago

Hi Scott... two questions:

R

Scott BonAmi mailto:notifications@github.com December 16, 2013 at 6:11 PM

"Out of the box" is precisely why I started /PFIncrementalStore/ :) This project still has a few more changes that need to happen before I list it on cocoapods, and even then I would consider it a development-only project until further testing can be done. That being said, I'd do the following (these are rough instructions off the top of my head):

User currentUser = <# current user #>; NSPredicate predicate = [NSPredicate predicateWithFormat:@"user = %@", currentUser];

NSError error = nil; NSManagedObjectContext context = <#Managed Object Context #>; NSFetchRequest fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"Appointment"]; [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"appointmentUser = %@", currentUser]]; NSArray results = [context executeFetchRequest:fetchRequest error:&error];

NOTE: /PFIncrementalStore/ adds additional fields necessary to keep everything synced. Steps for migrating your schema should be taken or your app may crash.

NOTE: /PFIncrementalStore/ will be submitted to cocoapods soon at which time the git declaration can be dropped from the Podfile.

— Reply to this email directly or view it on GitHub https://github.com/sbonami/PFIncrementalStore/issues/12#issuecomment-30720666.

sbonami commented 10 years ago

As this project is still pre 0.0.1 and only available via GitHub, I have yet to write full installation and usage instructions. I appreciate that you aim to continuously learn new tech and moreso that you have interest in PFIncrementalStore, but I believe this project may require a level of understanding and attention that is more advanced. At the point in which deem the project able to launch publicly, I would highly recommend you revisit as I still believe it will solve your goals. As we've both stated: better instructions, more testing, and an example project may make the project more easily digestible.