cocoa

Getting current working directory from a Sandboxed command-line app

岁酱吖の 提交于 2021-01-27 04:12:09
问题 I'm now trying to sandbox my command-line app which is written in Objective-C. Issue When the app was not sandboxed, I could get the directory where the user invoked the app using [[NSFileManager defaultManager] currentDirectoryPath] . However, after sandboxing, the app always returns for current directory /Users/{MY_ACCOUNT}/Library/Containers/{BUNDLE_IDENTIFIER}/Data no matter from where the command-line app was invoked. Example Code Actually, I wanna know the absolute path to the files

NSRect vs CGRect: y-axis inversion

半世苍凉 提交于 2021-01-27 02:47:23
问题 So I'm trying to convert an NSRect to a CGRect. I used NSRectToCGRect() which copies everything over finely, but does not take into account y-origin axis. The problem: A CGRect origin of (0,0) is the top left. NSRect origin (0,0) is bottom left. Thus an NSRect (0,0,100,100) box is positioned at the bottom left of your screen, while a CGRect (0,0,100,100) box is placed at the top left of your screen. I have a hack that fixes the y-origin through basic math: fixedOriginY = screenHeight - NSRect

NSRect vs CGRect: y-axis inversion

做~自己de王妃 提交于 2021-01-27 02:47:17
问题 So I'm trying to convert an NSRect to a CGRect. I used NSRectToCGRect() which copies everything over finely, but does not take into account y-origin axis. The problem: A CGRect origin of (0,0) is the top left. NSRect origin (0,0) is bottom left. Thus an NSRect (0,0,100,100) box is positioned at the bottom left of your screen, while a CGRect (0,0,100,100) box is placed at the top left of your screen. I have a hack that fixes the y-origin through basic math: fixedOriginY = screenHeight - NSRect

NSRect vs CGRect: y-axis inversion

試著忘記壹切 提交于 2021-01-27 02:46:10
问题 So I'm trying to convert an NSRect to a CGRect. I used NSRectToCGRect() which copies everything over finely, but does not take into account y-origin axis. The problem: A CGRect origin of (0,0) is the top left. NSRect origin (0,0) is bottom left. Thus an NSRect (0,0,100,100) box is positioned at the bottom left of your screen, while a CGRect (0,0,100,100) box is placed at the top left of your screen. I have a hack that fixes the y-origin through basic math: fixedOriginY = screenHeight - NSRect

Receive notification for power cord on/off in OSX Cocoa for the laptop

[亡魂溺海] 提交于 2021-01-24 09:55:18
问题 ALL, Does OSX sends any notification when the power cord is plugged/unplugged in the Mac laptop? Or plugging/unplugging the laptop from the docking station? It does send something on shutdown/reboot/wake-up/etc, but I didn't find anything for that specific event. Am I missing something? Or this is not available? TIA! 回答1: There are no high-level notifications, but the IOPowerSources framework can post a message to your run loop whenever the power state changes. My project has multiple

NSVisualEffectView stops working of NSWindow title bar is set to hide

放肆的年华 提交于 2021-01-22 08:50:02
问题 NSVisualEffectView seems to work just fine in a NSWindow, however it stops working (i.e. does not blur contents behind window) if I set the NSWindow's title bar to be hidden from Interface Builder. I don't see why the two are linked but would like to have a borderless window with the blur working - is this not possible? 来源: https://stackoverflow.com/questions/29596657/nsvisualeffectview-stops-working-of-nswindow-title-bar-is-set-to-hide

NSVisualEffectView stops working of NSWindow title bar is set to hide

旧时模样 提交于 2021-01-22 08:48:08
问题 NSVisualEffectView seems to work just fine in a NSWindow, however it stops working (i.e. does not blur contents behind window) if I set the NSWindow's title bar to be hidden from Interface Builder. I don't see why the two are linked but would like to have a borderless window with the blur working - is this not possible? 来源: https://stackoverflow.com/questions/29596657/nsvisualeffectview-stops-working-of-nswindow-title-bar-is-set-to-hide

Document-Based App autosave with storyboards

喜欢而已 提交于 2021-01-21 10:29:33
问题 In Document-Based Apps, using XIB files, when a new window is created its behaviour is: Be positioned and sized based on the position of the last active window. If the last active window is still visible then the new window should be cascaded so it doesn't directly overlap. However when using a storyboard this isn't done. See test project. 回答1: You can set shouldCascadeWindows on the window controller in your storyboard: select the window controller in the storyboard select the identity

How to change background color of NSSearchField (like in Messages app in OS X)

浪子不回头ぞ 提交于 2021-01-21 09:15:29
问题 I need to get this appearance of NSSearchField But it seems to be impossible to set backgroundColor with standard methods of Interface Builder. How i can achieve this? Subclassing NSSearchField and NSSearchFieldCell didn't help, because i loose all animations (when you click on search field and icon+text sliding to left) when implementing my own draw methods. 回答1: What your screenshot shows is just the standard look of NSSearchField when being placed under an NSVisualEffectView . That is, the

Multiple applications in a single bundle

亡梦爱人 提交于 2021-01-21 08:36:38
问题 I am developing a multi-platform presentation application which consists of two parts: An editor part and a viewer part. Both parts are developed as separate programs. The user edits the individual slides using the editor and the editor then launches the viewer whenever the user wants to see his presentation. On Windows the editor can simply run the viewer by doing a ShellExecute(). On Linux systems the editor could just fork() the viewer but on Mac OS X this looks like it could get