FAQ Database Discussion Community


App not showing in Notification Center for IOS8+

ios,iphone,cordova,ios8,nsnotificationcenter
I am working on Cordova app which is using Urbanaisrship push notification. When I load my build in to iPhone-4 which have version(7.1), I can see my app into device setting-->Notification Center. But when I load same build in to my other device Iphone 5s which have version 8.2 my...

How to detect the closing of the NofiticationCenter in Swift / Xcode?

ios,swift,nsnotificationcenter,viewdidload,viewdidappear
I have a UITableView and I want to to reload, when the NotificationCenter has been dismissed over the running app. override func viewDidLoad() { super.viewDidLoad() self.tableView.reloadData() NSNotificationCenter.defaultCenter().addObserver(self, selector:"dismissedNC", name: UIApplicationWillEnterForegroundNotification, object: nil) } func dismissedNC() { println("NC has been dismissed") // doesn't get printed self.tableView.reloadData() } Any ideas why it...

How to update UITableViewCells using NSTimer and NSNotificationCentre in Swift

ios,uitableview,swift,nstimer,nsnotificationcenter
NOTE: Asking for answers in Swift please. What I'm trying to do: Have tableview cells update every 1 second and display a real-time countdown. How I'm doing it currently: I have a tableview with cells that contain a label. When the cells are generated, they call a function that calculates...

NSManagedObjectContextDidSaveNotification best way to update the UI?

objective-c,core-data,nsmanagedobjectcontext,nsnotificationcenter
In my code i have an mainManagedObjectContext and a backgroundManagedObjectContext and its working great. I moved all my save code to the backgroundManagedObjectContext and merging the differences between the contexts via NSManagedObjectContextDidSaveNotification. Now I want to update my UI after NSManagedObjectContextDidSaveNotification. What is the best approach beside of a NSFetchedResultController...

Cocoa Posting an NSNotification from a subclass within a subclass

objective-c,cocoa,nsnotificationcenter,nsnotifications
I am having an issue with receiving an NSNotification that is being sent from an NSButton that has been subclassed to detect double clicks. Which itself is used within a subclass of NSView. When I post the notification to the default notification center it never arrives in my appDelegate where...

Adding observer after poster NSNotificationCenter workaround?

ios,nsnotificationcenter,delegation
Is it possible to assign a delegate or NSNotificationCenter observer to VC2 that is loaded after VC1, where post takes place? I have a tabbar app with multiple VCs. VC 1 is loaded first and the action to trigger a post takes place before VC2 is loaded. In VC2, I...

Xcode 6 - UIKeyboardDidShowNotification unrecognized selector

ios,swift,nsnotificationcenter,unrecognized-selector
I'm trying to scroll the view (to prevent the keyboard from hiding text fields), but I can't seem to get the keyboard notification to function properly. This code is based on Apple's documentation (see here). First, we add the listener in the viewDidLoad() of a UIViewController subclass. NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWasShown"),...

NSNotification addObserver selector could not open a NSBeginAlertSheet sheet on window

objective-c,cocoa,nsnotificationcenter,alerts
I have two different window Controllers. First is a custom panel window controller and another is main window controller. In panel window there is a panel window and there are button on that panel. On click of those buttons I am posting notification like : In PanelWindowController: -(IBAction)okAndCancelButtonClicked:(id)sender { [self...

What is a “non-weak zeroing reference”

objective-c,cocoa,memory-management,nsnotificationcenter,osx-elcapitan
In the OS X v10.11 beta release notes, I find the following: NSNotificationCenter and NSDistributedNotificationCenter no longer send notifications to registered observers that may be deallocated. If the observer is able to be stored as a zeroing-weak reference the underlying storage stores the observer as a zeroing weak reference. Alternatively,...

How to, applicationDidBecomeActive in Xamarin iOS?

ios,xamarin,monotouch,nsnotificationcenter
How do I do this in Xamarin iOS? ViewDidAppear is not called when Opening app from background The link below mentions the OnActivated method for Xamarin in the AppDelegate, but how do I subscribe my ViewController so it knows when the app comes from the background? https://forums.xamarin.com/discussion/10594/where-is-applicationdidbecomeactive-in-xamarin-ios...

Pass NSString values from one ViewController to Another using Notifications?

ios,nsnotificationcenter,nsnotification
How can I pass NSString values from ViewController1 to ViewController2 by using notifications in iOS? I have tried: ViewController1 - (void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incomingNotification:) name:@"test" object:nil]; } - (void) incomingNotification:(NSNotification *)notification{ NSString *theString = [notification object]; NSLog(@"theString value=%@",theString); } ViewController2 - (void)viewDidLoad { NSString *[email protected]"testing"; [[NSNotificationCenter defaultCenter]...

How to repeat the LocalNotification only once in a day

ios,swift,nsnotificationcenter,localnotification
I create a application in which application notify the users once in a day. For that I used the following code func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) { scheduleNoticaiftion() } // Schedule the Notifications with repeat func scheduleNoticaiftion() { //UIApplication.sharedApplication().cancelAllLocalNotifications() // Schedule the notification ******************************************** let notification = UILocalNotification() notification.alertBody...

object in addObserver is different

ios,nsnotificationcenter,addobserver
I'm have the following code: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil]; And the method uses a property of self: - (void)moviePlayerWillEnterFullscreen:(NSNotification *)notification { NSLog(@"%@", self.videoItem._id); } Sometimes (not always) the self object inside the handler is a different object (and an uninitialized one which causes a crash) I can't seem...

how to pass array to NSNotification in swift

swift,nsnotificationcenter,alassetlibrary
i have the following code which print the url of updated image override func viewWillAppear(animated: Bool) { NSNotificationCenter.defaultCenter().addObserver(self, selector: "assetChange:", name: ALAssetsLibraryChangedNotification, object: nil) } func assetChange(notification: NSNotification){ if var info:NSDictionary = notification.userInfo { var url:NSSet = info.objectForKey(ALAssetLibraryUpdatedAssetsKey) as NSSet var aurl:NSURL = url.anyObject() as NSURL println(aurl) } } this...

How to make NSNotificationCenter only run when a certain UITextField is selected

ios,iphone,swift,cocoa,nsnotificationcenter
I am using NSNotificationCenter to shift the main view frame up when a keyboard is shown. However, I only want this to work for when one UITextField is selected. Here is what I have so far: func getKeyboardHeight(notification: NSNotification) -> CGFloat { let userInfo = notification.userInfo let keyboardSize = userInfo![UIKeyboardFrameEndUserInfoKey]...

ViewController deinit after performing segue using Notification

ios,swift,notifications,nsnotificationcenter
I'm basically receiving a remote notification and I want to redirect my user to the correct VC as soon as he clicks the notification. I'm doing it using NSNotificationCenter to perform a segue from my rootVC, leading the user to the correct VC. NSNotificationCenter.defaultCenter().addObserver(self, selector: "chooseCorrectVC:", name:chatNotificationKey, object: nil) Since...

Programmatically open Notification Center / Today view

xcode,osx,cocoa,swift,nsnotificationcenter
Is there any way (that would be accepted by an AppStore review) how to open the today view of the Notification Center? I searched the docs for NSNotificationCenter but if there is a way, this seems to be the wrong place to look. My requirement is, that I am developing...

How to pass arguments to the selector in NSNotificationCenter?

ios,swift,selector,nsnotificationcenter
This code checks when the app becomes active and runs a specific method dataMain(). I added a argument to dataMain(productCode: String). NSNotificationCenter.defaultCenter().addObserver( self, selector: "dataMain", name: UIApplicationDidBecomeActiveNotification, object: nil) Is there any way I can pass the productCode argument to the selector?...

Dispatch group and NSNotification

objective-c,grand-central-dispatch,nsnotificationcenter,nsnotification
My issue is simple. I have 3 tasks, one is triggered by an NSNotification. How to I wait for all task to be completed before proceeding. So far, I tried using dispatch group but can't find a way to add the task triggered by NSNotification. (I tried adding the dispatch...

Swift NSNotification not working for all ViewControllers

ios,swift,uinavigationcontroller,nsnotificationcenter,viewdidload
In this Navigation Controller App, I have a button in the TAN ViewController that when clicked on posts an NSNotification. -Both the Blue (Root) ViewController and the Green ViewController are listening to this same notification -The Blue ViewController successfully responds to the notification's arrival -The Green ViewController DOES NOT respond...

On button action NSNotificationCenter Rises again the keyboard

keyboard-events,nsnotificationcenter
I am not able to sort of where is the mistake in my code . When i click the "Submit" button then the keyboard rises again. Here i am using the NSNotificatioCenter which scrolls the view according to keyboard height. Have a look on code below. -(void)viewDidLoad { [super viewDidLoad]; [[self...

iOS programmatically triggered segue is performed multiple times on success

ios,objective-c,iphone,segue,nsnotificationcenter
I connect my app to a rest API to log in the user. When the log in procedure is finished, I use the NSNotificationCenter to inform the controller of the successful log in and for the app to perform the segue to take the user ot the main menu. Here's...

Why @selector can call a method which is declared in an implementation file?

objective-c,cocoa,nsnotificationcenter
I have declared (between @interface and @end) and implemented a method in the .m file of Class A. For instance: - (void)zoneChange:(NSNotification *)note { NSLog(@"The system time zone has changed!"); } And in Class B, I want to send zoneChange message to a observer when the system zone is changed....

Today extension crashing with NSNotificationCenter

ios,swift,nsnotificationcenter,today-extension
I'm creating a today extension that grows/shrinks to save space. in the Notification Center, but I am having problems with the NSNotificationCenter. If I call the visibility() function, the view shrinks and grows normally, but if I try posting a notification, the extension fails and attempts to reload instead(at least...

How would I push a view upwards when keyboard is shown when user touches a text view?

ios,swift,nsnotificationcenter
I have a VC in which I have 3 elements (2 text fields at the top and 1 text view at the bottom). The text view at the bottom is unfortunately hidden when the keyboard appears. I'd like to push my view upwards when the user taps or touches the...

Handling UI update in a for loop - iOS

ios,objective-c,nsnotificationcenter,nsoperationqueue
I'm using NSNotificationcentre to update the UI from a for loop. The UI isn't updated until the execution is out of the loop. Is there way to handle this case? Here is my code below: - (void)uploadContent{ NSURLResponse *res = nil; NSError *err = nil; for (int i = 0;...