In OS X 10.9 (xcode 5.1), how to show local notification on top-right(menu bar) in my program? - objective-c

Why local notification is no supported by OS X 10.9? I know IOS has UILocalNotification Class.
I want to show some notification bellow menu bar which is generated by my program.
Is there any alternate way to do this? Or should I write my own local notification view?

It sounds like you are looking for NSUserNotification functionality, which goes along with the MacOS NSUserNotificationCenter.
I've linked the documentation at Apple to help you out.
As you are learning, many classes and objects supplied in the iOS SDK don't have exact same classes and objects in the MacOS SDK. Anything with "UI" in the framework name is usually meant only for iOS.

Related

NSTabView vs NSTabViewController -- When to use the controller?

The NSTabViewController was only introduced in OS X v10.10, so NSTabView already provides everything you need for creating a tab view. When would you use a NSTabViewController, and is it only there to be subclassed?
I would use NSTabViewController to get rid of a lot of code I used to have to write to have a tab view and transition between those views (most often done in Preference windows in Mac apps).
You'd obviously have to be 10.10 only, but these days that's a safe bet.
As for subclassing it, judging by the api I'd start without sub-classing it. You can set the style, the transition options (a nice benefit of using it!), and then call addTabViewItem: and let it do it's stuff.
If you compare iOS & OS X, you will feel OS X is bit deviated from MVC. OS X default 'new project' opens with AppDelegate as compared to iOS with 'ViewController'!
Now, it seems, Apple decided to make it by adding Controller as well. So that the view NSTabView is controlled by NSTabViewController.
And yes if you design to subclass it and use that should reduce your job. Same thing is mentioned even in Apple Documentation.

Watch Kit: is it possible to vibrate watch programmatically?

Is it possible to vibrate watch while Watch Extension is running? We can do it on iOS in this way (force iPhone to vibrate):
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
I hope there is something similar on WatchKit.
Update: I have added issue to Apple radar and recieved the answer:
Engineering has determined that your bug report (20019274) is a duplicate of another issue (19025053) and will be closed.
19025053 is still open.
Update 2: AudioServicesPlayAlertSound() not working on watch simulator with any sound ID. Seems like function is not supported.
You can now ask the Watch to vibrate if you target watchOS 2.0
To do this all you need to do is call playHaptic on a WKInterfaceDevice instance with any WKHapticType. In the example below it will play the notification haptic.
Swift 3
WKInterfaceDevice.current().play(.notification)
Objective-C
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];
You can further read the
Apple WKInterfaceDevice Documentation
That's a great question, but unfortunately the answer is no. WatchKit doesn't have any APIs available to control haptic feedback. If you would really like to see this feature supported, I'd suggest you file a radar as a feature request.
This is the answer in objective-c after watchOS 2
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];
With WatchKit, you have to remember that your code runs on the iPhone and not on the watch. Therefore, AudioServicesPlaySystemSound call from a WatchKit extension would run on the iPhone, not on the watch. It will make the iPhone vibrate.

NSOutlineViewDataSource protocol only shows up when importing Cocoa.h instead foundation.h

I was working on Lesson 49 of the Cocoa Programming on YouTube's apple programming channel and when I tried to make a delegate to the NSOutlineViewDataSource in my OutlineViewController.h file, Xcode did not know what I was talking about. I had NSObject as my superclass and it was importing Foundation.h like the video but it did not like the protocol. I had to change over to Cocoa.h to get it to work. Did Foundation change between Xcode 4.5 (I think that's what the video is using) and Xcode 6? I am running Xcode 6 on OSX 10.9.5
Thanks,
Patrick
Foundation.framework is much like its name says and is just the bare bones of the OSX and iOS frameworks. So stuff like strings, numbers, arrays, sets.
Note that Foundation isn't the same bunch of things on iOS and OSX but same principle, nuts and bolts.
To get all the widgets and shiny stuff that makes UI happen you need to import Cocoa on OSX or UIKit on iOS
Main moral of the story is don't trust tutorials too far as they are bound to be wrong at points.

Send notification to notification center in mountain lion

How would I be able to send a notification to the Notification Center in Mountain Lion from objective-c in my mac app? (not to be confused with nsnotificationcenter). I would like a link to a sample project or sample code posted.
Look into the NSUserNotification class. Once you have set it up, you can schedule it through the NSUserNotificationCenter class which will then handle the presentation to the user.

Example for startMonitoringSignificantLocationChanges

I am new to iPhone programming. I am looking for an example or a demo on how to use startMonitoringSignificantLocationChanges method with the CoreLocation Manager.
I am confused by the documentation because, I am not sure if the same delegate method is called as in the case of invoking startUpdatingLocation. (i.e. the delegate locationManager: (CLLocationManager *)manager didUpdateToLocation: (CLLocation *)newLocation fromLocation: (CLLocation *)oldLocation is called)
Any help on this would be appreciated. Also, I am testing it on the simulator by subclassing of CLLocationManager. This subclass provides a simulation of location services when running on the iPhone Simulator. Is there a better way to test this.
I have done a bit of testing with the significant change API. I posted a sample project on GitHub that lets you play with regular and significant location updates.
This question might also shed some light on what happens when you get woken up for a significant change event.
Update
Another thing you should be aware of, there is a bug in CoreLocation in 4.1. Basically if your app is in the background, then it will crash when core location tries to wake you up. It is fixed in 4.2.
There is a great video session on these new iOS 4.0 CoreLocation and MapKit features from WWDC 2010 that should be freely available in iTunes U for all registered iPhone developers.