Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this sync between two separate users? #12

Closed
Spokane-Dude opened this issue Dec 16, 2013 · 18 comments
Closed

Does this sync between two separate users? #12

Spokane-Dude opened this issue Dec 16, 2013 · 18 comments
Labels

Comments

@Spokane-Dude
Copy link

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

@sbonami
Copy link
Owner

sbonami commented Dec 16, 2013

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
Copy link
Author

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

@Spokane-Dude
Copy link
Author

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
#12 (comment).

@sbonami
Copy link
Owner

sbonami commented Dec 16, 2013

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 that are 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.

@Spokane-Dude
Copy link
Author

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
#12 (comment).

@sbonami
Copy link
Owner

sbonami commented Dec 17, 2013

"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
Copy link
Author

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
Copy link
Owner

sbonami commented Dec 17, 2013

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

sbonami commented Dec 17, 2013

I did say they were rough instructions 😉 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
Copy link
Author

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 😉 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
#12 (comment).

@sbonami
Copy link
Owner

sbonami commented Dec 17, 2013

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
Copy link
Author

How do I get your updates to PFIncrementalStore?

@sbonami
Copy link
Owner

sbonami commented Dec 17, 2013

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
Copy link
Author

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
#12 (comment).

@Spokane-Dude
Copy link
Author

Hi Scott... two questions:

  • Do I really need the Facebook, etc stuff? (my login info is self
    contained within the app)
  • When you say "attach PFIncrementalStore to my existing project", do
    you mean "Add files to project" ?

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
#12 (comment).

@sbonami
Copy link
Owner

sbonami commented Dec 18, 2013

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.

@sbonami sbonami closed this as completed Dec 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants