nsnotifications

How do I post a NSNotification when using Grand Central Dispatch?

╄→гoц情女王★ 提交于 2019-12-30 07:11:05
问题 I found that as predicted when I was writing an image to file that my UI was blocked for the duration, which was not acceptable. When I write the image to file I then post an NS Notification so that I can do some other specific jobs related to that completion. Original working but UI blocking code: -(void)saveImageToFile { NSString *imagePath = [self photoFilePath]; BOOL jpgData = [UIImageJPEGRepresentation([[self captureManager] stillImage], 0.5) writeToFile:imagePath atomically:YES]; if

How do I post a NSNotification when using Grand Central Dispatch?

你。 提交于 2019-12-30 07:11:04
问题 I found that as predicted when I was writing an image to file that my UI was blocked for the duration, which was not acceptable. When I write the image to file I then post an NS Notification so that I can do some other specific jobs related to that completion. Original working but UI blocking code: -(void)saveImageToFile { NSString *imagePath = [self photoFilePath]; BOOL jpgData = [UIImageJPEGRepresentation([[self captureManager] stillImage], 0.5) writeToFile:imagePath atomically:YES]; if

How to set alarm for selected days in iphone?

梦想的初衷 提交于 2019-12-30 07:06:33
问题 I want to set alarm for selected days of the week. It may be a weekday (mon, tue, wed, thu, or fri), weekend(sat, sun) or daily. How can i do this using local notifications? 回答1: If you have the time which you have to fire notification every day, you should do this NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *components = [[NSDateComponents alloc] init]; for (NSMutableArray * arrDay in self.namaztimes) { NSLog(@"Alarm Array: %@"

How should Finder Sync Extension and Main App communicate?

送分小仙女□ 提交于 2019-12-28 13:39:08
问题 My use case: I have a 'MainApp' which does the syncing of files. I would like that 'MainApp' handles all server calls regarding syncing and other REST API calls such as document-sharing, etc. On the other hand, I would have a Finder Sync Extension which would show sync-status icon overlays. It would also have a file-context-menu-item 'Share' which would present a Share dialog where users can choose with whom to share the file. Questions: How should FinderSyncExtension and MainApp communicate?

using UILocalNotification with core location

谁都会走 提交于 2019-12-24 17:13:00
问题 I have this code which send user notifications every time the distance between an event that occur in a local JSON file and his current location is < 100 meter asking him whether he is at that event or not , when he presses on yes then that event will be marked as attended. the thing is I tried to do that by using some code i found online but I'm not sure if it is the right way to do it, anyway i tested it on my iPhone and what happened is when i arrived to an event location it kept sending

NSFileHandle readInBackgroundAndNotify does not work

折月煮酒 提交于 2019-12-24 08:53:51
问题 Hi I'm using NSFileHandle's readInBackgroundAndNotify method to get notifications when a log file has been updated. I have the following code: - (void)startReading { NSString *logPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Logs/MyTestApp.log"]; NSFileHandle *fh = [NSFileHandle fileHandleForReadingAtPath:logPath]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter addObserver:self selector:@selector(getData:) name

How to migrate NSWorkspace notifications to Swift 4?

佐手、 提交于 2019-12-22 15:25:53
问题 In Swift 3 I registered for sleep and wake notifications with this code: let notificationCenter = NSWorkspace.shared.notificationCenter notificationCenter.addObserver(self, selector: #selector(AppDelegate.sleepListener), name: NSNotification.Name.NSWorkspaceWillSleep, object: nil) notificationCenter.addObserver(self, selector: #selector(AppDelegate.wakeUpListener), name: NSNotification.Name.NSWorkspaceDidWake, object: nil) but after migrating to Swift 4, I get this error after applying the

Where and how do I register an object for receiving a Notification?

我只是一个虾纸丫 提交于 2019-12-22 06:23:08
问题 For example, when memory gets low, the System sends a UIApplicationDidReceiveMemoryWarningNotification notification. That's all Apple says in its docs at that point. But where does this notification come from, and to which method is it sent? Or where and how do I register what that I get notified? 回答1: It is sent to the notification center, where all notifications are centralized. An object that wants to get informed about this notification registers itself to the notification center by

If add an observer for a notification in the AppDelegate, do I need to bother removing it?

大憨熊 提交于 2019-12-22 05:35:07
问题 In the AppDelegate's didFinishLaunchingWithOptions : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contextChanged:) name:NSManagedObjectContextDidSaveNotification object:nil]; This is so I can merge changes to the data from other threads. Question: Do I need to bother removing this listener in applicationWillResignActive or applicationWillTerminate ? It doesn't seem like there's a point. I guess I'm asking if it's normal to have listeners like this in the main loop

How To set Custom repeat interval For Nslocal Notification…?

房东的猫 提交于 2019-12-22 05:10:42
问题 i am New to iphone Development .I Am Trying To Use NslocalNotification In My Project I Need To Give Remeinder For Every 2Hours or For Every Two Days Or For Every Two Months Etc..Currently I am Using NslocalNotification Repeat Interval .But Its Working For Only Every Minute For Every Hour using Nscalender .... NSString *InterVal=[freQuencyArr objectAtIndex:index-2]; NSString *InterValType=[freQuencyArr objectAtIndex:index-1]; if(![InterVal isEqualToString:@"Every"]) { result=[InterVal intValue