cocoa

Cocoa Key Value Bindings: What are the explanations of the various options for Controller Key?

When I bind a control to an NSArrayController using Interface Builder, there are a variety of options under the "Controller Key" field in the bindings inspector. I understand what "arrangedObjects" is, and I semi-understand what "selection" is, but I'd love to see a really nice explanation of all the options and when to use each one. Th...

Core Data Migration error message "'Model does not contain configuration 'XYZ'.'"

I have a Managed Object Context to which I add two different SQLite stores. I use Configurations in the Mananged Object Model to assign certain entities to one store and other entities to the other. The Configurations are called "UserDB" and "MainDB". Everything works okay until I try to use automatic migration. After creating a new Man...

How to optimize Core Data query for full text search

Can I optimize a Core Data query when searching for matching words in a text? (This question also pertains to the wisdom of custom SQL versus Core Data on an iPhone.) I'm working on a new (iPhone) app that is a handheld reference tool for a scientific database. The main interface is a standard searchable table view and I want as-you-t...

Can I suppress the authentication dialog in a Cocoa WebView?

I'm using a Cocoa WebView object and I'd like to suppress the authentication dialog that pops down when the user types in the wrong credentials. The server is sending back a Www-Authenticate response header which I believe is triggering the dialog. Can I somehow intercept this header before it triggers the authentication challenge? Or i...

Does re-fetching NSFetchedResultsController do anything?

I have a fetched results controller with a predicate on my Thing entity that looks like this: "thingDomain.domainCurrentAccount !=NULL". It finds all of my Thing objects that are in the current domain. The current domain is defined by a one-to-one relationship between the Account entity and one of the Domain entities. Each Thing belongs ...

NSXMLParser Question

I'm writing a RSS feeder and using the NSXMLParser to parse an XML page for me. Everything works well. This is the code that handles the asynchronously connection: static NSString *feedURLString = @"http://www.example.com/data.xml"; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:feedURLString]]; feed = [[[NSU...

Cancelling operation with connection inside

I have a NSOperation that downloads some data using NSURLConnection, it looks somewhat like this: .... - (void)main { .... while (!self.isCancelled && !self.isLoaded) { [NSRunloop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NDate distantFutute]]; } .... } The problem is that from time to time connection han...

How to write a Core Data predicate to filter to specific sub-entity types?

I have a superentity called FObject with several subentities, say Foo1, Foo2, and Foo3. I have a number of tableviews that should show information about different collections of the subentities, so for example, one shows only Foo2s and Foo3s while another shows all of them. How do I write a predicate to filter on the subentity type, giv...

Properties of relations in Core Data

In order to better learn both Cocoa and Core Data, I decided to build an application that holds cooking recipes. However, while trying to create the CD model, I already got stuck. These are three of the classes, simplified: Recipe: name ingredients instructions Ingredient: name unit (liter, teaspoon etc) Of course, the ingredients ...

Drawing in NStextField

Hey ho! If you wanted to implement a highlighting for specific substrings in a NSTextField like on the screenshot (Tweetie.app) how would you do it? :) Thanks for your help! ...

Possible to get the hostname of an IP using SystemConfiguration?

I'm using the SystemConfiguration framework to get the current IP from the dynamic store in my app. Is it possible to get the hostname from the dynamic store as well? The current IP could be local, so I'm trying to get the returned value to be something like "mymac.local" or "2adg3.dsl.lgtpmi.sbcglobal.net", depending on how I'm connect...

Tutorial for converting PHP applications to Cocoa?

I do a lot of coding in PHP and MySQL, but I'm looking at moving my applications to a desktop environment in order to allow users to access the data offline, and periodically receive updates from a central online database. For the time being, however, I'm looking for a decent tutorial on how to convert PHP applications to Cocoa, and how...

determine schema field type in SQLite, CSV, or Excel

I am working on an Cocoa project using SQL databases, or CSV/Excel files as the input. Right now, I have hard-coded the SQL schema for the SQLie files I am importing (For example, the program would know that the first column is a STRING, second column is a INT... etc.). I am wondering if there's any C or Objective-C library or method to...

Black Arrow Status Item

I am working on a IM client for OS X, and I have the design in mind, but I need help with the code. On Snow Leopard, when you click a dock item, you get something like this: What I was thinking of was something like that: (photoshop) This is the basic idea, but it has to be resizable so that it can include more stuff, like so (stil...

NSError domains / custom domains - conventions and best practices

NSError requires a domain, which I understand segments the range of error codes. One would anticipate that there exist somewhere a registry of domain.error code but I've not been able to discover one. Supposedly this could used for looking up localized descriptions for errors. Does anyone have any set of known best practices for deali...

NSTableView keyDown: and mouseDown:

I've been working on a menubar note-taking application for Mac. It is written in Objective-C and Cocoa, and I'm using BWToolkit with it. My problem is getting keyDown: and mouseDown: events in a BWTransparentTableView which is a subclass of NSTableView. I just can't get it to work. I've tried searching the Internet, and some places say t...

Problem when NSOutlineView cells have same value

I have a Mac OS X application that uses an NSOutlineView with two columns: key and value, where you can edit the value column. I either have a NSString or a NSDictionary in a row. The code for the value of the cells is like this: - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem...

SecPKCS12Import() from Security.framework fails on OS X 10.6

When I attempt to use SecPKCS12Import() from the Security framework as provided by Mac OS X 10.6, the result code is always errSecUnimplemented, regardless of the arguments provided. Furthermore, the linker is unable to find symbols for the constants relevant to this function declared in SecImportExport.h (i.e. kSecImportExportPassphra...

Dynamically invoke a class method in Objective C

Suppose I have Objective C interface SomeClass which has a class method called someMethod: @interface SomeClass : NSObject { } + (id)someMethod; @end In some other interface I want to have a helper method that would dynamically invoke someMethod on a class like this: [someOtherObject invokeSelector:@selector(someMethod) forClass:...

Checking if a nsstring matches another string

Suppose I have a string "167282". How can I check if the string contains "128"? Is there any provision to know the percentage of the 2nd string that matches the first string? (If all the characters of the 2nd string are present in the first string or not.) Please help and thanx in advance. ...