cocoa

CoreData: numberOfObjects in Section incorrect

帅比萌擦擦* 提交于 2020-01-24 20:28:06
问题 I'm using CoreData in an iOS app to save a simple list of location objects (name, coordinates). I've run into a situation twice now, after a memory warning, when the CoreData records appear to become corrupt. Specifically, (in tableView:numberOfRowsInSection:) NSUInteger numObjects = [[[fetchedResultsController sections] objectAtIndex:section] numberOfObjects]; returns 4 for section == 0. Then (in tableView:cellForRowAtIndexPath:) aLocation = [fetchedResultsController objectAtIndexPath

How to bind a NSTextField to a raw string while displaying another attributed string?

怎甘沉沦 提交于 2020-01-24 20:14:29
问题 I'm using view-based NSTableView and would like to allow users to edit text in place. Cocoa typically has superb support for this, but I am not sure how to bind the value of NSTextField to one string while displaying a slightly different string to the user, as shown below. For example, when user clicks on a text field or presses enter key to edit, the field editor should only be filled with exportTest.zip and not exportTest.zip Shared , and whatever edit user makes should only affect the

How to bind a NSTextField to a raw string while displaying another attributed string?

拈花ヽ惹草 提交于 2020-01-24 20:13:22
问题 I'm using view-based NSTableView and would like to allow users to edit text in place. Cocoa typically has superb support for this, but I am not sure how to bind the value of NSTextField to one string while displaying a slightly different string to the user, as shown below. For example, when user clicks on a text field or presses enter key to edit, the field editor should only be filled with exportTest.zip and not exportTest.zip Shared , and whatever edit user makes should only affect the

Xcode “Build and Archive” button disabled for Mac app. Why?

江枫思渺然 提交于 2020-01-24 19:40:27
问题 I am building a Mac app, but the "Build and Archive" menu item is disabled. I am running Xcode 3.2.4 and OS X 10.6.5. Any suggestions? 回答1: Download and install the "Application Tools" package fixed it for me. Links to the Application Tools download can be found on the index page for the Mac developer program. 来源: https://stackoverflow.com/questions/4382804/xcode-build-and-archive-button-disabled-for-mac-app-why

InterfaceBuilder NSButton connect to NSViewController Cause “Could not connect action, target class NSObject does not respond to”

依然范特西╮ 提交于 2020-01-24 19:35:16
问题 I have a view-based NSTableView whose "file's owner" is the ViewController . I dragged a button(for deletion) on the custom NSTableCellView , so I want to click the button and delete the current row from tableView, but when add a row the debug console tells me " Could not connect action, target class NSObject does not respond to deleteAction: " I m using the NSArrayController binding the NSTableView(add action is triggered successfully). I also got another weird problem, I try to subclass

What is the proper way to pass data between two view controllers inside a NSSplitViewController?

眉间皱痕 提交于 2020-01-24 19:34:08
问题 Overview: My app structure looks like this: NSSplitViewController `- SidebarViewController | `- NSOutlineViewController | `- NSTreeController | `- SidebarEntity (static) `- ContentViewController `- NSTableViewController `- NSArrayController `- ContentEntity (CoreData) Task: I would like to filter ContentEntity list based on selection in the sidebar. Problem: I have no idea what is the proper way to pass selection changes over from SidebarVC to ContentVC . Environment: XCode 8.2.1, Swift 3, OS

Why does an NSTextField leave artifacts over an NSTableView when the table scrolls?

自作多情 提交于 2020-01-24 16:08:29
问题 I want to put a text label over a scroll table but the label conflicts with the drawing of the scrolling. Here you can see a test where I've intentionally put the label half out of the table and scroll up in the table, which results in the part of the label overlay being dragged below until it exits the window. Also, when I go to the other end of the table and scroll down, sometimes the label seems to be redrawn and chunks of it go up along with the scroll: It seems that the table is

Access NSArray from a NSTimer Interval = EXC_BAD_ACCESS

六眼飞鱼酱① 提交于 2020-01-24 13:33:27
问题 I have some code that looks like this: actualColor = 0; targetColors = [NSArray arrayWithObjects:[UIColor blueColor], [UIColor purpleColor], [UIColor greenColor], [UIColor brownColor], [UIColor cyanColor], nil]; timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(switchScreen) userInfo:nil repeats:YES]; And in the selector i have this: - (void) switchScreen { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; [UIView

Sizing a control to fit its container in Interface Builder

∥☆過路亽.° 提交于 2020-01-24 12:50:06
问题 Let's say I have a split view, and I want to fill half of it with a table view (a fairly common use case, I would think). Is there any way to tell the table view to size itself to fit the split view or do I really have to size it manually? 回答1: As far as I know, doing it manually is the only way to go. However, if you turn on "snap to cocoa guidelines", the inner view will snap to the edges of the enclosing view as you drag towards them. This makes it easier than having to manually mouse the

Binding to an NSDictionary's “allValues” array

ぃ、小莉子 提交于 2020-01-24 10:27:49
问题 Am I misunderstanding something about bindings? I bind (an NSArrayController's content) to an NSDictionary's "allValues" array, and it thinks it's empty. I bind to a random object with a property that I've set to be that same NSDictionary's "allValues" array, and it works fine. Is this expected behavior, or am I doing something wrong? Furthermore, if this is expected, what is the standard way to deal with this? Making relatively purposeless objects just to hold arrays in properties so I can