cocoa

Programming for the Apple infared remote controls

白昼怎懂夜的黑 提交于 2020-01-23 08:16:00
问题 How do I get started with programming for the Apple infared remote control? To start with, I only intend to support one control, and one type of receiver, that on the current unibody MacBooks. What I mean by programming, is, how do I get started with writing an OSX, preferably Cocoa if there are APIs, app which intercepts commands from the control, and then sends commands to the OS. For example, as a start, I'd like to be able to simply pick up a key press from the remote control, and then

NSInternalInconsistencyException Could not load nib ind bundle

余生长醉 提交于 2020-01-23 06:27:26
问题 I am developing an application for the iPad. The application has following details: Base SDK: 4.2 Deployment Target: 3.2 The application is a game application and it has got 10 rounds. In each round I am loading 6 controllers and after the completion of each round again the same cycle starts. The application works fine till 4 rounds but at the end of 4th round it crashes given following error: "NSInternalInconsistencyException Could not load nib ind bundle:" I have checked for everything

NSCGImageSnapshotRep, how get bitmapData

自闭症网瘾萝莉.ら 提交于 2020-01-23 06:22:10
问题 I got a image with only one representation, and that was a NSCGImageSnapshotRep . I tried [NSCGImageSnapshotRep bitmapData] but, the class has no selector for bitmapData . Someone knows this class? How can I get the bitmapData ? I'm getting this NSImage from Webkit [DOMElement renderedImage] . Create bitmap of a DOMElement Objective C The correct use is [NSBitmapImageRep representationUsingType:id properties:id] , this means doesn't work in the case. I didn't think about compatibily, I'll be

NSCGImageSnapshotRep, how get bitmapData

我的未来我决定 提交于 2020-01-23 06:21:20
问题 I got a image with only one representation, and that was a NSCGImageSnapshotRep . I tried [NSCGImageSnapshotRep bitmapData] but, the class has no selector for bitmapData . Someone knows this class? How can I get the bitmapData ? I'm getting this NSImage from Webkit [DOMElement renderedImage] . Create bitmap of a DOMElement Objective C The correct use is [NSBitmapImageRep representationUsingType:id properties:id] , this means doesn't work in the case. I didn't think about compatibily, I'll be

Why do my xcode builds always go to the iPad simulator instead of the iPhone simulator?

蹲街弑〆低调 提交于 2020-01-23 05:59:56
问题 I just installed the latest SDK from Apple so I can start learning iPhone / iPad app development. However, I'm having a stupid issue: all my builds get run in the iPad simulator instead of the iPhone simulator, and I have no idea how to change it. 回答1: For now, the iPhone Simulator 3.2 SDK is iPad-only. Test using the iPhone Simulator 3.1.2 SDK edit: as of the upcoming 4.2 SDK, the iPhone and iPad versions of iOS have been unified under a single SDK. 回答2: On your build selector dropdown,

Detect if cursor is hidden on Mac OS X

帅比萌擦擦* 提交于 2020-01-23 05:17:41
问题 Is there a programmatic, non-private-API way to detect whether the mouse cursor is hidden on Mac OS X? (As occurs, for example, when typing into a text field.) NSCursor has hide and unhide but no isHidden . I'm wondering if there is some other API which might do what I want. C-based APIs are fine. 回答1: Try CGCursorIsVisible() (returns a BOOL ). 来源: https://stackoverflow.com/questions/5026660/detect-if-cursor-is-hidden-on-mac-os-x

Finder Scripting Bridge to Shutdown

佐手、 提交于 2020-01-23 04:08:09
问题 I tried to use Application Scripting Bridge to send my Mac to sleep. The code look like the following: #import "Finder.h" FinderApplication *Finder = [SBApplication applicationWithBundleIdentifier:@"com.apple.finder"]; [Finder sleep]; But it doesn't work. Any ideas why it doesn't work? No compiling errors or warnings, but it doesn't work… 回答1: As I posted in this answer, I've been using the following code for over 8 years without issues: MDRestartShutdownLogout.h: #import <CoreServices

Can I draw to the same CGContextRef from multiple threads?

依然范特西╮ 提交于 2020-01-23 02:12:12
问题 I'm making an app where I want to draw a lot of shapes - circles, boxes, lines, etc. Millions of them. To test the performance of this, I threw together this simple UIView. Note that credit is due - I got inspired by this project. import UIKit let qkeyString = "label" as NSString var QKEY = qkeyString.UTF8String let qvalString = "com.hanssjunnesson.Draw" as NSString var QVAL = qvalString.UTF8String public class RenderImageView: UIView { var bitmapContext: CGContext? let drawQueue: dispatch

Adding an NSControl to IKImageBrowserCell

吃可爱长大的小学妹 提交于 2020-01-23 01:44:11
问题 I've built a custom IKImageBrowserCell which is displaying my images in an IKImageBrowser without any issues. I'd like to try and override the built in IKImageBrowser delete image functionality. Currently 'out of the box' you can select an image, or multiple images and press BACKSPACE to delete. I'd like to add an NSButton or similar to enable that same functionality on each image. I've added the following code to show a delete icon on the IKImageBrowserCell when it is selected: - (CALayer *)

How to authorize user with Google in OS X Cocoa application

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-23 01:06:06
问题 I am using Firebase in my OS X application. I am trying to add Google Authentication. This is an example for iOS. Question is: How to obtain Google OAuth access token in OS X application? 回答1: Firebase auth can be integrated with Google sign in on OS X the following way using the GTMOAuth2 pod. import Cocoa import GTMOAuth2 import Firebase class MainWindowController: NSWindowController { let ref = Firebase(url: "https://xyz.firebaseio.com") override func windowDidLoad() { super.windowDidLoad(