cocoa

implementing protocol methods in objective-c

If I have an protocol (say UIPickerViewDataSource) and I implement its required methods, do I need to declare those methods in the header file of my class? At the moment I'm not doing so and I get a warning of incomplete implementation (although everything works fine). If I do add the required methods in the then I don't get such warnin...

Strict vs loose typing when overriding a method

I have a class called AddressCard from an example in "Programming in Objective C", and I'm implementing a isEqual: method. The signature of this method in NSObject uses loose typing for the parameter: - (BOOL)isEqual:(id)anObject OTOH, the sample code in the book uses strict typing: - (BOOL) isEqual:(AddressCard *) aCard I'm not s...

How can I make an object disappear on the Mac?

So basically I just want to have the user click on an NSButton, and have it disappear once it is clicked. How can I do that? ...

Why is my app crashing when I modify a Core Data relationship in an NSOperation subclass?

Background I've got the following tree of objects: Name Project Users nil John nil Documents nil Acme Project Acme Project <--- User selects a project Proposal.doc Acme Project ...

encrypt a file on iphone-sdk

Hello, I'd like to have a file encryption functionality for my iphone application. For desktop based applications i used the function below to encrypt relatively small files: - (NSData *)aesEncrypt:(NSString *)key { // 'key' should be 32 bytes for AES256, will be null-padded otherwise char keyPtr[kCCKeySizeAES256+1]; // room for term...

How can i forbid tab switching the focus into a NSView control

I have a sidebar NSOutlineView in my main window. I want the user to be able to switch the focus with the tab key through all views in the main window, but he should not be able to give the NSOutlineView the focus with a tab key. I know that with - (BOOL)canBecomeKeyView { return NO; } - (BOOL)acceptsFirstResponder { return NO; } i ...

Debugging MacOSX Cocoa applications with command line gdb (without XCode)

I use a cross platform toolkit which wraps Objective-C so i do not/can not use XCode. Just the pure command line and plain old makefiles. I compile my source code with "gcc -Wall -g -O0 " but when running it under gdb control i do not get the stack frames or valid source code lines. First: What can i do to get this work. Second: How ca...

is a character already in the range?

I need to get, is a character already in the range. The character string is of type NSMuttableString. For example, I have a string of "52.648" and I need to know is a "." symbol is already in the string. How can I do it? ...

NSTextView: loading RTF, view does not update correctly until mouse is moved over the control

I have a pretty simple window that contains an NSTextView. I'm calling readRTFDFromFile: to load and display an rtf file on disk. I'm calling this from within the awakeFromNib handler. When the view appears on screen it only partially displays the contents of the rtf, the button portion of the view is blank/white. However, when the mous...

Mac OS X - Cocoa timeline/curve editing control

I'm looking for a Cocoa UI widget for timeline/graph editing (Like the graph editor in After Effects, or the Timeline patch in Quartz Composer), and I haven't found anything similar. Any suggestions? I was hoping to avoid reinventing the wheel on this one :) ...

Way to listen in on all Apple Events?

I'm looking for a way to listen in to all Apple Events send by any program to any other program. There was an app, AEMonitor, that used to do this but it is abandonware as of now. Is there a known way to do this via cocoa, carbon, etc? Any help MUCH appreciated. -- Target OS is 10.6 -- Carification: I'm looking to monitor ALL appl...

-initWithFrame method is being called twice

Hi, I have written a code to load a nib file which consists of a view and a tableview. Everything works fine as expected but when i run the program, sometimes the views gets loaded, sometimes it doesnot. I mean, when i run my application say for the first time, it will open a proper GUI window with all the views in place. when i re-open ...

FileSize Problem - Cocoa

Hello, I've written methods that help me get the size of files/folders and translate the result in a human readable string. Problem is, when this size exceeds about 2.1GB, the number returned changes to a random negative number, like "-4324234423 bytes", which is useless. Things I've found out about & done about this issue: 32GB is l...

NSSplitter how to prevent proportional space distribution on resize.

I have a window with a source list sidebar at the right side and a content view on the left both inside an NSSplitView. When i resize the window, the additional space is distributed to the source list and the content view. How can i make the source list to maintain its fixed width. All Apple applications are doing this so i hope i just ...

using variables for unit testing only

I am writing unit tests for an app for iPhone using objective c. I want to use some variable only when compiling for test case for example #ifdef UNIT_TESTING @synthesize requestFinished, networkAvailable;//etc #endif now where should I define UNIT_TESTING that when I compile for unit tests it should enter this code block.... otherwi...

Callback for kAudioSessionProperty_AudioRouteChange not called in one case

Hi all, I want to be notified if headphones are plugged in or plugged out. I'm currently doing this using a property listener like this: AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, myCallback, self); This works perfectly well in all cases except in one, it goes like this: Launch, iPhone is unmuted, no he...

NSNotificationCenter: Why bother calling removeObserver?

The gods have parachuted many habits into my isolated jungle village, such as: - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; } Their ways are strange to me, yet I still seek to understand them. Why bother cleaning loose ends up if the instance is going away? Will the reference/r...

Disable Full Keyboard Access for App

Can "Full Keyboard Access" (System Prefs -> Keyboard -> (Radio) All Controls) be controlled with some API? It causes major issues when this thing is on in my app (like buttons not working as expected etc ... it has some custom UI) Regards, Erik ...

How to reposition mac desktop in cocoa

Is there a function that allows you to manipulate the desktop like Dashboard->Manage Widgets? The desktop appears to reposition itself and slide up. What I want to do is not just slide the desktop when my toolbar is temporarily active but have the entire desktop resize. I assume if you can grab a handle to manipulate the desktop like Da...

Obj-C: Convert a video's current time(double) to frame(decimal).

Hi, My app plays a movie and I must keep track of, and interact with the playback time. I use the currentPlaybackTime property to grab a double value of the movie's playback time. I want to use this to trigger some if statements at certain points, But first it would be really helpful if I could convert the value into a value with only 2 ...