cocoa

How to use NSScanner?

Hi, I've just read Apple's docu of NSScanner. I'm trying to get the integer of that string: @"user logged (3 attempts)". I can't find any example, how to scan within parentheses. Any ideas? Here's the code: NSString *logString = @"user logged (3 attempts)"; NSScanner *aScanner = [NSScanner scannerWithString:logString]; [aScanner sca...

Why am I having trouble with a deep copy in Objective C?

I'm assuming my understanding of how to perform a deep copy isn't just there yet. The same with some sub-optimal memory handling that I'm performing down below. This code below probably depicts a shallow copy, and I believe that's where my problem might be. I have some cookie-cutter code for an example that looks like the following: NSA...

What describes objective-C and Cocoa Bindings best?

I have trouble understanding Cocoa Bindings. Can someone explain me what this is all about, in an way that is humanly perceivable? ...

What does "Controller Key" mean in Interface Builder > Inspector > Bindings?

I can't find in the Docs where they explain all those fields and what they mean. Especially "Controller Key" is not clear to me. ...

What is the job of an Object I am binding to?

When I use Interface Builder > Inspector > Bindings to set up an binding for one of my view Items (i.e. an textfield), then I have to specify an object to which this view item will be bound to. So I am wondering now, what exactly is the job of this object I specify in "Bind to:"? I assume that Interface Builder automatically creates som...

What describes an "Outlet" best in objective-c / Cocoa?

Can someone explain in an humanly understandable way what an "Outlet" is? ...

What's the point of the "Controller Key" property in IB in the Inspector > Bindings pane?

Apple says: An attribute of an NSController object. When binding to an NSController object, you use this field to select the first entry in the key path. The menu associated with this field displays the properties available on the selected controller object as a convenience. You can type the name of the property or simply select it f...

Documents and Nib files: What does apple mean by "Document"?

I don't understand how the term "Document" is used in objective-C and cocoa. When I build an Application, why do I have an "Document"? That makes no sense to me. I could have an Application like an Image Editor, wherein I can open like 100 Images at same time. So every Image is a Document and has its own Nib file? Can someone explain tha...

Objective-C + Cocoa: Internationalization with Nibs. Is that really a good idea?

In the Apple Docs they say that a Nib enables internationalization by just translating the Nib into many languages. I am thinking now about a worse but realistic scenario: You have made a huge user interface. Then you translate this into 25 languages. So you get 25 different Nibs. You also get a huge redundancy in styling and defining th...

What describes the "File's Owner" best in objective-c / coca Nib?

Unfortunately, the explanation of File's Owner is pretty short at the Apple docs. I know it is an proxy object. But what's really the point about that "File's Owner" object? What is it good for? ...

Where do I find all Apple Guides for objective-c and cocoa?

I find that the xcode-builtin-documentation reader is hard to use. I want to see the root of all Guides available, to get an idea of how long I will have to keep reading until I can start. All the time some new Guide pops up to me, and I am wondering how many they are. Is there an overview somewhere? ...

Does it make sense to first learn Cocoa for Leopard and then Cocoa Touch for iPhone?

Actually I don't care too much about Mac OS X development. I want to do only iPod Touch and iPhone development. But anyways, I started learning Cocoa and Objective-C. But it seems like there are many differences between Cocoa and Cocoa Touch, so I am wondering if I am actually wasting my time. Should I just jump directly into iPhone topi...

Objective-C / Cocoa,

Let me summarize that shortly: A "First Responder" in a NibFile is an Object, which represents the UI control element that has the user's focus. So if the user klicks on an UI control, the Nib sets that clicked UI control as First Responder. In my app I could make an outlet to that "First Responder" from the Nib, so that I could for exam...

Objective-C / Cocoa, "First Responder" - Did I get that right?

Let me summarize that shortly: A "First Responder" in a NibFile is an Object, which represents the UI control element that has the user's focus. So if the user klicks on an UI control, the Nib sets that clicked UI control as First Responder. In my app I could make an outlet to that "First Responder" from the Nib, so that I could for exam...

Writing a string to NSPasteBoard

I cannot get this method to return YES: - (BOOL) writeToPasteBoard:(NSString *)stringToWrite { return [pasteBoard setString:stringToWrite forType:NSStringPboardType]; } I have verified that stringToWrite is coming through properly, the method just always returns NO. Any ideas? Here is the rest of the class: @interface ClipBoard...

Displaying a list of views

Here's a mockup: I have been trying to find some sample code that showcases something like this -- a scroll view with a list of custom views. Haven't found anything. I've been trying to find some open source projects that does this (that isn't Adium with a million files and lines of code), but haven't found anything there either. I'v...

CFReadStreamHasBytesAvailable polling - best practices

I'm currently polling my CFReadStream for new data with CFReadStreamHasBytesAvailable. (First, some background: I'm doing my own threading and I don't want/need to mess with runloop stuff, so the client callback stuff doesn't really apply here). My question is: what are accepted practices for polling? Apple's documentation on the subj...

Objective-C / Cocoa: What is the "Application" proxy object in Interface Builder / Nib good for?

Does someone have a easy-to-understand example what this Application object is good for? Why is it there? And in what cases do I need it? ...

Get Return Value of NSTimer's Target

I have an NSTimer which is setup like this: [NSTimer scheduledTimerWithTimeInterval:0.5 target:timerTarget selector:NSSelectorFromString(targetSelector) userInfo:nil repeats:YES]; How can I get the return value of the timerTarget method? ...

Storing an NSImage in a Core Data Model

What is the correct way to store an NSImage in a Core Data Model? I have assumed adding an Attribute to an Entity and giving it the Type "Binary" should work, but it is not working. I have a table with a column of NSImageCells and it is not showing anything. ...