cocoa

NSManagedObjectContext's propagatesDeletesAtEndOfEvent set to false causes error on save

荒凉一梦 提交于 2020-01-14 14:13:50
问题 I have a pair of Core Data Entities of One-to-Many relationship. Department <-(optional) (delete rule: Cascade) (optional)->> Item Item <-(optional) (delete rule: Nullify) (optional)->> Department Item is a tree node-like entity, which also has a relationship to itself. The tree can grow quite large (more than 10 thousands nodes in a root branch). There are a parent background NSManagedObjectContext and a main-queue one as the child. In the hope of making deletion of Items feel faster, I set

Retina version of an image always used on non-retina display

耗尽温柔 提交于 2020-01-14 13:47:11
问题 In Cocoa application I've got 16x16 and 32x32 @2x version of an image: . When the image is displayed in NSImageView Mac OS X always picks higher-resolution version (i.e. downscales the @2x image on non-retina displays instead of using the 1:1 version). (IB on the left = good, running app on the right = downscaled mess) Of course I've got both images added to the project (as image.png and image@2x.png ). If I delete the @2x image from app bundle then OS X will display the lower-resolution

other application window close event

谁都会走 提交于 2020-01-14 13:46:27
问题 How to detect other applications window close event or notification in cocoa /carbon based application? eg. if there are multiple windows in TextEdit application how to detect close event on particular window rather than whole application itself. 回答1: How to detect other applications window close event or notification in cocoa/carbon based application? The way to do that sort of thing is to use MacOS X's accessibility model. There's a good example in the documentation that'll give you an idea

NSUndoManager : separate multiple changes in one run loop cycle

…衆ロ難τιáo~ 提交于 2020-01-14 13:35:32
问题 I'm using [undoManager registerUndoWithTarget::] to add some changes to undo stack. However, sometimes happens, when in one run loop cycle two changes added to the same group, so they are reverted at once, which is not behavior I'd like to have. I want to separate these two changes to have two items in undo stack. How to correctly implement this? Use [NSObject performSelector: ] to call second undo addition in the next run loop cycle, or whatever else? Thanks. 回答1: As you’ve noticed, by

Using NSPoint Mouse Tracking on NSView

亡梦爱人 提交于 2020-01-14 13:32:07
问题 I have this method in App Delegate that makes a window and content view but I want to be able to track the mouse using an NSPoint on entered and exiting the view. The problem is I do not want to make a NSView Custom class and want to do it all within my AppDelegate. The mouse tracking (at the bottom) does not work, any suggestions? - (void)toggleHelpDisplay { // Create helpWindow. NSRect mainFrame = [[NSScreen mainScreen] frame]; NSRect helpFrame = NSZeroRect; float width = 75; float height =

NSFetchRequest not catching objects that have a changed property

淺唱寂寞╮ 提交于 2020-01-14 13:28:11
问题 I have run into a weird problem with CoreData on MacOsX 10.6 using an SQL store. I have an NSManagedObject subclass called Family with attribute name and a relationship personList connected to another NSManagedObject subclass called Person with attribute firstname and inverse relationship family . A Person has only one family , and a family can have several Person s. Say I have a Family object family pointing to the family 'Doe' with 2 Person (John and Jane) connected to it and I do the

Where do I register a ValueTransformer in Swift?

耗尽温柔 提交于 2020-01-14 13:09:09
问题 I'm trying to use a ValueTransformer (né NSValueTransformer ) in Swift that is being used by the first window that my application opens. Value transformers need to be registered with ValueTransformer.registerValueTransformer(_:forName:) before they can be queried by the user interface runtime. The documentation for NSValueTransformer recommends registering value transformers in +[AppDelegate initialize] . However, Swift doesn't allow you to override +initialize . I tried to register from

Where do I register a ValueTransformer in Swift?

[亡魂溺海] 提交于 2020-01-14 13:08:53
问题 I'm trying to use a ValueTransformer (né NSValueTransformer ) in Swift that is being used by the first window that my application opens. Value transformers need to be registered with ValueTransformer.registerValueTransformer(_:forName:) before they can be queried by the user interface runtime. The documentation for NSValueTransformer recommends registering value transformers in +[AppDelegate initialize] . However, Swift doesn't allow you to override +initialize . I tried to register from

How do I check whether an NSData object contains a sub-NSData?

我怕爱的太早我们不能终老 提交于 2020-01-14 06:59:08
问题 I have an NSData object which contains some data I need. What I wanted to do is to find out the position of data "FF D8" (start of JPEG data) How can I achieve work like this? 回答1: First get the range, then get the data: // The magic start data object is only created once safely and // then reused each time static NSData* magicStartData = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ static const uint8_t magic[] = { 0xff, 0xd8 }; magicStartData = [NSData

can't open image with NSOpenPanel

假如想象 提交于 2020-01-14 06:04:03
问题 I use below code for open image with NSOpenPanel but doesn't work //panel=NSOpenPanel NSString *imgg = [NSString stringWithFormat:@"%@",panel.URL]; self.imgUser.image=[NSImage imageNamed:imgg]; 回答1: The problem is that +[NSImage imageNamed:] doesn't load an image by URL. If you read the documentation, it explains what it actually does: it looks for an image stored in the cache under that name, or stored in the app's bundle or AppKit's framework under that filename. There are a large number of