nsnotificationcenter

Mac Mountain Lion send notification from CLI app

隐身守侯 提交于 2019-12-28 05:30:55
问题 How can I send a notification to the notification center from a command line app? My attemps so far compile and run, but don't succeed in notifying me. Example #import <Cocoa/Cocoa.h> int main(int argc, const char * argv[]) { NSLog(@"Running notifications"); NSUserNotification *note = [[NSUserNotification alloc] init]; [note setTitle:@"Test"]; [note setInformativeText:@"Woot"]; NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter]; [center

pass NSString variable to other class with NSNotification

旧巷老猫 提交于 2019-12-28 04:15:11
问题 I want to pass a NSString from one class to another class and add that NSString to an NSMutableArray in my second class. I'm believe i can use NSNotification for this, but i don't know how to pass an variable over notification. My code would something like this: //class1.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property(strong,nonatomic)NSString *variableString; @end //class1.m #import "ViewController.h" @interface ViewController () @end @implementation

Detecting Network Connectivity Changes using Reachability, NSNotification and Network Link Conditioner in Swift

蹲街弑〆低调 提交于 2019-12-27 11:38:54
问题 I'm trying to integrate network connectivity detection into my app, however it seems that somewhere along the line I have made a mistake as my network changes are not being detected/printed out into the console. As mentioned in the post, I'm currently using these following classes and tools for the job: Reachability {.h, .m} NSNotificationCenter Network Link Conditioner Code In the AppDelegate.Swift , I've set up the NSNotificationCenter to detect changes: func application(application:

Why does this audio session fail to recognise an interruption?

余生颓废 提交于 2019-12-25 08:48:29
问题 My app synthesises audio from a lookup table. It plays audio successfully but crashes the moment I try to stop playing. Audio playback only needs to exit without restarting so the requirements for handling the interruption are basic. I reread Apple’s Audio Session Programming Guide including the section Responding to Interruptions. However the method handleAudioSessionInterruption does not seem to register an interrupt so I’m obviously missing something. EDIT See my answer. When I began work

NSNotification.Name.UIKeyboardWillShow crash - Unable to find cause

北城以北 提交于 2019-12-24 10:40:04
问题 Users of my app have reported a random crash. I have integrated CrashAnalytics which is giving the following details : __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20. The line number indicated is 154, which is : self.notesView.content.frame = CGRect(x: self.notesView.content.frame.origin.x, y: self.notesView.content.frame.origin.y, width: self.notesView.content.frame.size.width, height: self.notesView.content.frame.size.height - keyboardFrame.size.height). Following is the code I

sleep mode vs notification center open

旧街凉风 提交于 2019-12-24 00:44:47
问题 in both, 1) iPhone goes in Sleep mode 2) Open notification Center It calls - (void)applicationWillResignActive:(UIApplication *)application Is there any way to identify if this method is called because device went in to sleep mode or by opening notification center? 回答1: There are some hacks to detect lock/unlock, but nothing official that couldn't break with a future iOS release. 回答2: OK, When you lock your screen/iPhone goes to sleep mode , the front most app(Your app) will go to background

Clicking on Like all the view should show like objective C

こ雲淡風輕ζ 提交于 2019-12-23 01:11:52
问题 When I select Throwback -> Description occurs if I click on like button the like button changes to unlike and " like count=1099" increases. If I press back I want this unlike to be displayed next to Throwback let say in a label and again select Throwback button should display unlike and like Count should be 1100. please Help how can i achieve this ? //DetailOfUser.m #impot"DetailsOfStories.h" @interface DetailOfUser ()<UITableViewDelegate,UITableViewDataSource> { NSMutableArray

How can I act on Core Data iCloud sync notification when the app is in the background?

烂漫一生 提交于 2019-12-22 08:27:31
问题 I have an iOS app that uses Core Data with iCloud sync. The app is working perfectly and syncing across multiple devices. As part of my implementation my app is registered for the: NSPersistentStoreCoordinatorStoresDidChangeNotification This notification works perfectly with the app in the foreground, but what I would like to do is fire a local notification to let the user know that the iCloud data in the app has changed, whenever the app is in the background and a sync notification comes in.

How to know where crash for postNotificationName:object:userInfo

早过忘川 提交于 2019-12-22 08:25:48
问题 Is there some method to know crash reason in Xcode 4.6? The crash stack is : Exception Type: SIGSEGV Exception Codes: SEGV_ACCERR at 0xd9f2c061 Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x3a74f5aa objc_msgSend + 10 1 Foundation 0x33157599 -[NSNotificationCenter postNotificationName:object:userInfo:] + 73 2 UIKit 0x347830cd -[UIApplication _handleApplicationSuspend:eventInfo:] + 733 3 UIKit 0x346f91e7 -[UIApplication handleEvent:withNewEvent:] + 2459 4 UIKit 0x346f86cd -

ios notifications to “dead” objects

感情迁移 提交于 2019-12-22 05:34:11
问题 I have a number of UIViews coming into view, then going out of view and being unused. However, I believe some of them are still receiving notifications even after they are gone wich is causing problems. On the UIView "parent" container: if(self._content != nil && [self._content respondsToSelector:@selector(presentMe:)]) { [self._content presentMe:NO]; } On the UIView "child": [[NSNotificationCenter defaultCenter] <-- EXC_BAD_ACCESS (code=1, address=0x70000008 postNotificationName:PRESENTING