nsnotificationcenter

iOS Detect system volume level change. private API or not? AVSystemController_SystemVolumeDidChangeNotification

十年热恋 提交于 2019-12-04 03:06:10
Can listening to AVSystemController_SystemVolumeDidChangeNotification NSNotification be considered (during the App Store review process) as using private API? In my application I need to display and update the current volume level. Volume indicator should be updated after pressing hardware volume buttons and after volume change in MPVolumeView slider. I've searched solution how to get notification or event of hardware volume button press and had found a number of solutions. For example, iPhone Detect Volume Keys press. and How to get audio volume level, and volume changed notifications on iOS?

NSNotification removeObserver problem

99封情书 提交于 2019-12-04 00:57:15
I am either brain damaged or I am lacking of some understending of NSNotificationCenter The problem is that if I create an observer and in the next line will try to delete it like so: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAllVisibleMapViews) name:@"ClearVisibleMaps" object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self forKeyPath:@"ClearVisibleMaps"]; I get *** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <MyApp 0x592db70> for the key path "ClearVisibleMaps" from <NSNotificationCenter

How to check internet connectivity in ios?

对着背影说爱祢 提交于 2019-12-03 21:51:55
How can I check whether the app is connected to the internet or not? currently, I am using this code in my appdelegate.m file dispatch_queue_t connectivityThread = dispatch_queue_create("com.gm.kart.connectivity", NULL); dispatch_async(connectivityThread, ^{ while (true){ if([GMMConnectivity hasConnectivity]) NSLog(@"%@", @"connected"); else NSLog(@"Not connected"); usleep(10000000); } }); and when I click my login button I want to do a check whether the internet is connected or not using NSnotificationcenter ? Please help me After download bellow example. http://developer.apple.com/iphone

singleton for location updating multiple views

非 Y 不嫁゛ 提交于 2019-12-03 20:48:11
I want to update user location in ALL views, after the locateButton in the navbar is pressed in ANY view. I've started by creating a singleton. Location.h #import <Foundation/Foundation.h> #import <CoreLocation/CoreLocation.h> #import <MapKit/MapKit.h> @interface Location : NSObject <CLLocationManagerDelegate> @property (nonatomic, strong) CLLocationManager* locationManager; + (Location*)sharedSingleton; @end Location.m #import "Location.h" @implementation Location { CLLocationManager *locationManager; CLGeocoder *geocoder; CLPlacemark *placemark; } @synthesize locationManager; - (id)init {

NSMetaDataQuery never calls back with NSMetadataQueryDidFinishGatheringNotification

南笙酒味 提交于 2019-12-03 18:05:57
问题 For an iCloud plugin I'm writing, I subscribe my iCloud manager class to these iCloud NSMetaDataQuery observers: // Add a predicate for finding the documents NSString* filePattern = [NSString stringWithFormat:@"*.%@", @"*"]; self.metadataQuery = [[NSMetadataQuery alloc] init]; // Before starting to query, it is required to set the search scope. arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]]; // It is also required to set a search predicate. [self.metadataQuery setPredicate:

Xamarin NSNotificatioCenter: How can I get the NSObject being passed?

烂漫一生 提交于 2019-12-03 17:48:10
问题 I am trying to post a notification in a view from my app to another one using NSNotificationCenter. So in my destination class I create my observer as follows: NSNotificationCenter.DefaultCenter.AddObserver ("ChangeLeftSide", delegate {ChangeLeftSide(null);}); and I have my method: public void ChangeLeftSide (UIViewController vc) { Console.WriteLine ("Change left side is being called"); } Now from another UIViewController I am posting a notification as follows: NSNotificationCenter

keyboard size given by NSNotificationCenter

余生长醉 提交于 2019-12-03 13:52:00
I want to add a accessoryView on a keyboard called from a UISearchBar. Since UISearchBar does not implement this property, I've just created a toolBar. Following Apple's documentation on the matter, I've decided to use notification center not only to know when the keyboard is called but also to know the size of the keyboard, which changes depending on the orientation. I've followed the example on the documentation and, on the keyboardWasShown method, I call an animation which will show the toolBar on top of the keyboard. Something like this: -(void)keyboardWasShown:(NSNotification*

Is NSNotificationCenter thread safe?

五迷三道 提交于 2019-12-03 12:00:48
Can I post a notification in a given queue and receive it on another? I want to use notifications to communicate different queues, but I'm not sure if this is safe... No. Notifications are delivered in the same thread that they are sent from, this you will need to re-send it in some way to get the notification to your thread. No. Apple's docs on the subject say: " Regular notification centers deliver notifications on the thread in which the notification was posted. [...] At times, you may require notifications to be delivered on a particular thread that is determined by you instead of the

Is removing a NotificationCenter observer that was created with closure syntax by name adequate?

ぃ、小莉子 提交于 2019-12-03 11:36:37
I have a few notifications that were created using block / trailing closure syntax which look like this: NotificationCenter.default.addObserver(forName: .NSManagedObjectContextObjectsDidChange, object: moc, queue: nil) { note in // implementation } Which I was later removing by name, like this: NotificationCenter.default.removeObserver(self, name: NSNotification.Name.NSManagedObjectContextObjectsDidChange, object: moc) My Question Is this adequate? Or do I absolutely need to save the NSObjectProtocol to it's own property and remove that property with the following syntax? NotificationCenter

Instance was deallocated while key value observers were still registered with it

一曲冷凌霜 提交于 2019-12-03 11:27:47
I've got a UITableView. Here I got different cell's. Each cell has a model. With KVO and NotificationCenter the cell listen to the model for changes. When I leave the ViewController I get this error: An instance 0x109564200 of class Model was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: <NSKeyValueObservationInfo 0x109429cc0> ( <NSKeyValueObservance 0x109429c50: Observer: