Questions tagged [nsapplication]

NSApplication is the central class in Apple's AppKit framework.

The NSApplication class is the central class in Apple's AppKit framework (). It is responsible for starting the main run loop and provides the central framework for your application’s execution.

References:

178 questions
8
votes
5 answers

How to check Mac OS X version at runtime

I am using below code to check OS X version at runtime. if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_10) { /* On a 10.10.x or earlier system */ } But this condition return false on 10.10.4 OS X. I am using Xcode 6.3.2. According…
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
8
votes
1 answer

Disabling/enabling an application menu item

In trying to learn the very fundamentals of menu handling. My test app's menubar has 3 menus -- namely "TestApp", "File" and "Help". I find I can remove these menus entirely, simply by calling say: NSMenu* rootMenu = [NSApp mainMenu]; [rootMenu…
Bender
  • 357
  • 5
  • 15
7
votes
1 answer

macOS: Is there any way to know when the user has tried to quit an application via its Dock icon?

Is there any way for a Cocoa application to detect when the user has tried to quit it via its Dock menu, and not by some other method? Normally it's possible to catch and respond to quit events using the application delegate's…
Bri Bri
  • 2,169
  • 3
  • 19
  • 44
7
votes
1 answer

NSApplication resigning front most application status: hide v. deactivate

I've got an application that needs to become the front most application after a timer expires and resign the front most status when the timer is started by pressing a button, e.g. click "start timer" -> app resigns front most application timer…
Frank R.
  • 2,328
  • 1
  • 24
  • 44
7
votes
1 answer

Why NSApplicationDelegate method openFiles: is being called multiple times on a multiple drag to the dock icon?

I have a Mac OS X application that implements the -(void)application openFiles: method to react to dragged files on the application icon. I have a list of allowed filetypes in the document types section of my target info settings and the Finder…
7
votes
5 answers

Cocoa: int main function

I'm curious, what role does the int main function play in a Cocoa program? Virtually all of the sample code I've been looking at has only the following code in main.m: #import int main(int argc, char *argv[]) { return…
Arthur Skirvin
  • 1,210
  • 1
  • 12
  • 14
7
votes
3 answers

Detecting Full screen applications on mac

I am developing a simple application in Cocoa, and I want to detect whether any application is running in full screen mode. Is this possible? Through runningApplications API, I can get various informations but there is no specific property related…
7
votes
2 answers

How to use WebView on xcode 4.5.1

I'm new to programming and I need to embed a website in my application (which is blank; I only want to embed the website right now). I've been searching for it since 5:00 PM (It's now 9:30 PM) and I still didn't find anything about that. What code…
Cedric Berger
  • 117
  • 1
  • 2
  • 9
6
votes
4 answers

Click-through buttons and not raising the window

The iTunes mini-player (to give just one example) supports click-through where the application isn't brought to the front when the play/pause and volume controls are used. How is this done? I've been looking through Apple's documentation and have a…
user103152
5
votes
1 answer

Why sendAction: doesn't work while performSelector: does?

I have a custom class that supports the target-action mechanism but oddly in this specific case, when I try to call the action by executing: [NSApp sendAction:action_ to:target_ from:self] it doesn't work, but this way does: [target_…
Carlos Barbosa
  • 3,083
  • 5
  • 30
  • 30
5
votes
1 answer

NSApplication vs UIApplication

What Is the difference between UIApplication and NSApplication? (As I am not getting it from their documentation...) Can someone give me some useful links for detailed explanation about their differences? Also, What is the key role of…
viral
  • 4,168
  • 5
  • 43
  • 68
5
votes
1 answer

NSApplication keyWindow is nil during applicationDidFinishLaunching

Starting with a blank OS X application project, I add the following code to applicationDidFinishLaunching. func applicationDidFinishLaunching(aNotification: NSNotification) { let app = NSApplication.sharedApplication() guard let window =…
Price Ringo
  • 3,424
  • 1
  • 19
  • 33
5
votes
1 answer

What exactly should I pass to -[NSApp activateIgnoringOtherApps:] to get my application to start "naturally" in comparison to most other OS X apps?

When I learned how to start NSApplications on my own, the code I used (based on here and here) did [NSApp activateIgnoringOtherApps:YES]; which forces the app to the front at startup. I'd like to know what most other apps do. I want to be able to…
andlabs
  • 11,290
  • 1
  • 31
  • 52
5
votes
1 answer

How is it that Cocoa GUI Class Runs without invoking NSApplication or NSRunLoop

Why does the following code work ? It's a small Cocoa program that uses NSOpenPanel to select a file and open it in Emacs.app. It can be run from the command line with the starting directory as an argument. How does NSOpenPanel run without…
Colin
  • 2,089
  • 25
  • 34
5
votes
3 answers

How to launch Apps, from my App, with a custom parameter so I can check whether the app was launched by me?

I'm working on this app that launches other apps. I'm listening to app launches using: [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(appLaunched:) name:NSWorkspaceDidLaunchApplicationNotification …
Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76
1
2
3
11 12