eaManager = [EAAccessoryManager sharedAccessoryManager];
[eaManager registerForLocalNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(gotDevice) name:EAAccessoryDidConnectNotification object:nil];
[eaManager connectedDevices] is always empty.
How can I pair to a accessory?
You need to connect your iPhone to a Made for iPod program device which provides a protocol for being accessed by the External Accessory framework. There aren't many of those out there right now. I believe that TomTom's iPhone Car Kit is one of them, but I can't think of others.
Related
If an entry is changed in core data on another device, NSLog messages show that it's noticed the changes, but NSPersistentStoreDidImportUbiquitousContentChangesNotification is not being called. It takes until a save on my first device for it to know to update my tableview.
This is my code:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(iCloudUpdates:)
name:NSPersistentStoreDidImportUbiquitousContentChangesNotification
object:nil];
Anybody know why this might not be working?
First option:
If your problem is a delay in updating both devices, that is normal behavior, Apple doesn't guarantee update timing, but it is usually fast.
If on the other side the problem is that iCloudUpdates method is not called make sure that signature is correct, should be :
-(void)iCloudUpdates:(NSNotification*)notification {
// do your stuff here
}
Second option:
at time of writing, iOS 5 has big big problem with iCloud and CoreData, I recently shipped my application without iCloud support.
If you want to know what is going on turn logging on for both CoreData and iCloud by putting:
-com.apple.CoreData.SQLDebug 1
-com.apple.coredata.ubiquity.logLevel 3
in your scheme manager, under run->arguments tab.
If you see some strange errors in 'destination' device that's the case of iCloud not working for being bugged.
I think the problem with your code is that in the "addObserver" you've set the object to nil. The object should be your persistentStoreCoordinator as shown below.
__weak NSPersistentStoreCoordinator *psc = self.context.persistentStoreCoordinator;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(iCloudUpdates:)
name:NSPersistentStoreDidImportUbiquitousContentChangesNotification
object:psc];
I have a requirement that is the app should disappear after install and when incoming or outgoing call, soon after the call the app should prompt and display the screen.
How disappear app after installation?
How detect incoming and outgoing call?
How display screen after ending of incoming and outgoing call?
The main thing is that i am making this for personal not of app store. So please if you have any idea about then give full suggestion and ideas.
Thanks in advance...
Use following notification to find the call status.Add CoreTelephony.framework
#import <CoreTelephony/CTCall.h>
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(callReceived:) name:CTCallStateIncoming object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(callEnded:) name:CTCallStateDisconnected object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(callConnected:) name:CTCallStateConnected object:nil];
I've started working with the External Accessory Framework and the Apple Camera Connector. I've got some barebones code working but am seeing some odd behavior.
Basically: when I connect the Camera Connector, I get three events
- EAAccessoryDidConnectNotification
- EAAccessoryDidDisconnectNotification
- EAAccessoryDidConnectNotification
So it sees the device connecting, then disconnecting, then connecting. I've tried manually connecting the device slowly, quickly, etc. - doesn't make a difference.
The code I am using to set up notifications is boilerplate (below). Is there any known reason why I might be getting that connection hiccup?
(fwiw - I am planning to use this with the Bass MIDI lib to determine when a keyboard has been connected/disconnected).
--thanks!
- (void)viewWillAppear:(BOOL)animated
{
// watch for the accessory being connected
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(_accessoryDidConnect:)
name:EAAccessoryDidConnectNotification
object:nil];
// watch for the accessory being disconnected
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(_accessoryDidDisconnect:)
name:EAAccessoryDidDisconnectNotification
object:nil];
[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];
}
I am looking at a project which was provided me by my organization, for study.
The problem is that in this project I found some code which I never saw before.
Please tell me why the following code is written.
-(void)notifications
{
[[NSNotificationCenter defaultCenter] addObserver: self selector:
#selector(hideViews) name: #"Hide" object:nil];
}
This problem arose because this project has only some code for designing.
Sorry if this is a silly question...
You should read up on how notifications work in Cocoa. Consult Apple's documentation for more information: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/Reference/Reference.html
Basically, NSNotificationCenter is a class that broadcasts NSNotifications from one object to potentially many observing objects. One object can post a notification
[[NSNotificationCenter defaultCenter] postNotificationName:#"NotificationName" object:self];
and other objects can listen for this notification.
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(notificationHandler:) object:theObjectThatPostedTheNotification];
Then, when the first object posts the notification, NSNotificationCenter will notify the other observing object, and notificationHandler: gets called.
I'd like to pause my app when the user pauses music on his headphones.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(playbackStateDidChange:)
name:MPMusicPlayerControllerPlaybackStateDidChangeNotification
object:[MPMusicPlayerController iPodMusicPlayer]];
works well. However, this is also triggered on an incoming phone call.
I added
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(appLostFocus:)
name:UIApplicationWillResignActiveNotification
object:[UIApplication sharedApplication]];
Unfortunately, this is triggered after the pause is detected.
Any ideas?
There is no documented way of doing this. It is probably doable with private APIs, but you know the song.