I'm attempting to submit a job using the XGrid API. I've opened a connection, and that seems to work ok, although it sometimes doesn't open, but when I do the following:
jobSubmissionMonitor = [controller performSubmitJobActionWithJobSpecification:jobSpecification gridIdentifier: nil];
[jobSubmissionMonitor addObserver:self forKeyPath:#"outcome" options:0 context:NULL];
My observeValueForKeyPath is never called. Any idea what that would be?
I've solved this. Turns out that Xgrid does not seem to work well when you've got the garbage collector enabled.
Related
I am working on a Mac & iOS App, with iCloud CoreData in between to synchronize the data.
When I update some thing from iOS App, and the updates are already migrated to the PersistentStore in Mac App while the Mac App is running. The problem is I cannot find an effective way to force the NSArrayController to reload all data from the store.
tried -(void) fetch:(id)sender; only can see the delete or added entity, but the updated model property not refreshed...
Please help. Thanks
If you see the latest data in the managed object context, but not in the array controller, you want:
[_yourManagedObjectContext processPendingChanges];
[_yourArrayController fetchWithRequest:nil merge:YES error:&error];
[_yourArrayController rearrangeObjects];
I use this in a Mac/iOS iCloud app to update the Mac app's data when the iCloud store changes.
Following is the reply from Apple's Developer Technical support. It worked for me. Thanks all for providing solutions.
For the OS X app, when reloadFetchResults is called, you can ask the NSManagedObjectContext to reset itself and perform the fetch again.
- (void)reloadFetchedResults:(NSNotification *)note
{
NSDictionary *userInfoDict = [note userInfo];
NSManagedObjectContext *moc = self.coreDataController.mainThreadContext;
// this only works if you used NSMainQueueConcurrencyType
// otherwise use a dispatch_async back to the main thread yourself
//
[moc performBlock:^{
[self mergeiCloudChanges:userInfoDict forContext:moc];
[moc reset];
[self.tableArrayController fetch:self];
}];
}
I've found that
[self.managedObjectContext reset];
[myArrayController fetch:self];
forces my NSTableView (with NSArrayController) to re-populate and display newly processed NSManagedObjects.
in case someone else finds this...
in my case, I was building the array from user interaction (not Core Data), and then trying to show the tableView when they were done (on the same window)... and of course... seeing nothing!
[arrayController rearrangeObjects];
just before I wanted to show the tableView fixed it for me.
I have implemented a login item as I was recommended in this post. In the helper app I launch the main app using NSWorkspace method launchApplication:showIcon:autolaunch:, sending YES to autolaunch parameter.
The problem is in following: I need to check if the applications was autolaunched not to show start tooltip. The only variant I found is [[NSUserDefaults standardUserDefaults] boolForKey:#"autolaunch"], and it returns NO always.
The problem could be solved using launch arguments - but sandbox, unfortunately, cuts them too.
Is there something I missed?
I use the following code to hide the launched application:
[[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL fileURLWithPath:appPath] options:NSWorkspaceLaunchAndHide configuration:nil error:nil];
If you want to set additional parameters, you can give the method a custom configuration dictionary.
If you have the launcher inside the application bundle:
NSString *appPath=[[[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:#"MacOS/myApp"];
I am working on Core Data syncing over iCloud between two Mac applications. I have it mostly working (based on http://timroadley.com/2012/04/03/core-data-in-icloud/) - data is being synced, but I'm never getting the content change notification I need to merge the changes into my local context.
In my AppDelegate's managedObjectContext method:
NSManagedObjectContext * moc = [[NSManagedObjectContext alloc]
initWithConcurrencyType:NSMainQueueConcurrencyType];
[moc performBlockAndWait:
^{
[moc setPersistentStoreCoordinator:coordinator];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(mergeChangesFrom_iCloud:)
name:NSPersistentStoreDidImportUbiquitousContentChangesNotification
object:coordinator];
}];
My observer function never gets called:
- (void) mergeChangesFrom_iCloud:(NSNotification*) notification
{
NSLog(#"Merging changes from iCloud");
// everything past here is irrelevent - this log message never appears
The data store is most certainly being synced - deleting a record in app A and forcing a table reload in app B results in a Core Data fault failure as expected for unmerged changes. Quitting and restarting app B shows the correctly updated data.
A breakpoint on the addObserver call shows it is being called. A breakpoint in mergeChangesFrom_iCloud shows that it is not.
Why is the coordinator apparently never sending the NSPersistentStoreDidImportUbiquitousContentChangesNotification as the documentation (and tutorials) claim it should? Where can I begin debugging this?
Update
The mystery deepens. Using the Core Foundation function shown here - NSNotificationCenter trapping and tracing all NSNotifications - I do not see NSPersistentStoreDidImportUbiquitousContentChangesNotification appear at all among the mass of notifications flying by.
It looks like it's not being posted at all - nor do I see any other Core Data related notifications after the initial load happens on startup.
so what I'm trying to do here is the following: let's say the user has already installed my app, app "A", from the store. On certain conditions, app "A" will open an URL pointing to a specific app page,app "B", on the App Store passing a redemption code so the user of app A is able to download app "B" without paying any additional money. So here's what I'm doing:
NSString *urlBase = #"https://phobos.apple.com/WebObjects/MZFinance.woa/wa/freeProductCodeWizard?code=";
NSURL *urlRedemptionCode = [NSURL URLWithString:[urlBase stringByAppendingString:code]];
[[UIApplication sharedApplication] openURL:urlRedemptionCode];
This is working fine, so the question is: how do I know that the download of app "B" was completed correctly (or with errors) so I can take appropriate action in app "A"?
Thanks so much.
You could use NSURLConnection in combination with NSURLRequest and NSURLResponse instead of directly calling [[UIApplication sharedApplication] openURL:yourURL].
NSURLConnection will allow you to set a delegate that will be notified when:
Data is (partially) received
Connection failed
Download finished
etc.
Check Using NSURLConnection at the official documentation.
In my application, I have registered the NSUserDefaultsDidChangeNotification notification in awakeFromNib along with my other notifications (which are working fine). I register it just as shown below, which appears to be correct:
- (void)awakeFromNib
{
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:#selector(myAction:) name:NSUserDefaultsDidChangeNotification object:nil];
}
and my action method appears to be correctly formatted as well:
- (void)myAction:(NSNotifcation*)notifcation
{
NSLog(#"foo);
}
For unknown reasons, however, it refuses to fire at all. No matter how many of the application's defaults are changed, it never fires even once. Am I registering wrong or is something else the cause? Has anybody else experienced this problem in the past?
Have you tried using [NSNotificationCenter defaultCenter] instead of the workspace notification center?