cocoa

Forcing Reading of a Text Field Before Dismissing Modal Dialog in Cocoa

In a Mac OS X Cocoa application, I have an application-modal dialog with text fields that are bound to the Shared User Defaults Controller. If I edit a text field, and then tab away from it before hitting the OK button, then everything works as desired. However, if I start editing a field, then hit the Return key to trigger OK, the old ...

Problem with initiating UITableViewCells based on indexPath.row

I have the following method that should populate the cells of my UITableView with data from an array. I want to get the data from the array using the row that the data is being loaded into as the index. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { cellComments=(FullCommentC...

Objective-C/Cocoa: Do I have a memory leak here?

I have a calling method that looks like the following: -(void)callingMethod { NSMutableString *myStr = [[[NSMutableString alloc] initWithCapacity:0] autorelease]; myStr = [self calledMethod]; } And my called method: -(NSMutableString*)calledMethod { NSMutableString *newStr = [[NSMutableString alloc] initWithCapacity:0];...

UITableView cells loading correctly initially but then changing

The following method loads data from an array into custom cells of UITableView. The data is loaded in correctly. However, when I scroll down data in the above cells (the cells not visible) are changed to seemingly random elements in the array. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *...

Objective-C: Why am I getting a compile error when importing a header file?

I'm curious what some reasons might be as to getting a compiler error for simply importing a header file. If I comment it out, everything compiles just fine -- the header/implementation for the class I'm trying to import into one of my UIViewController's get passed the compiler without any warnings. However, as soon as I include it, I ge...

OpenGL or QuartzComposer for creating OS X widgets

I was watching http://www.youtube.com/watch?v=XiqgmAYrd3c and was thinking it might be kind of fun to create some NSView/UIView-system compatible widgets that had some of the interactions found in the video. Some of them involve some fluid 3-D animation. Has anyone tried using OpenGL or maybe Quartz Composer to create widgets similar to ...

How to show some swf file in a webView with the App PictureBrowser?

I saw a App named PictureBrowser in the /Leopard/Developer/Examples/WebKit. I found that this App can show the images only in a webview. Now I want to show some swf flash swf files in this webview , How to do ? I thought this is a problem with javascript , Now I can show the two html file in this ,somebody can help to resolve this proble...

iphone NSURLConnection simultaneous requests limit

Is it possible to make simultaneously two requests in parallel to the same server using NSURLConnection? I'm trying to do it, and it looks like the second request do not start until the first one finishes. ...

Another question about iPhone application state

Hi, I have another question about restoring application state, on the iPhone. Simple data (like the selected tab) can be stored in NSUserDefaults, but it is not enough. I want to restore the whole state, including the Navigation Controllers (go to the sub-sub-sub View Controller). My problem is that my application is divided in severa...

Best route to creating a Calendar based Date picker for Cocoa?

I'd like to implement a date picker using a calendar. Before I go ahead and try to build one, is there something that does this already? I've looked at the date picker in Interface Builder and it's pretty much just a text field as far as I can tell. And looking (albeit quickly) through the developer docs, it seems there's plenty of dat...

Why declare a method in a Category without implementing it?

I'm reading the source code of an open-source project and I've encountered the following category definition in an implementation file: @interface QCView (Private) - (void)_pause; - (void)setClearsBackground:(BOOL)flag; @end At first I thought that the setClearsBackground method was being added to the QCView class definition. But when...

How do I serialize an object to file using NSKeyedArchiver in NSPropertyListXMLFormat_v1_0 format?

Hopefully that title is clear enough. Anyways, it seems: [NSKeyedArchiver archiveRootObject:rootObject toFile:path]; is restricted to NSPropertyListBinaryFormat_v1_0. I need the format to be human readable [so xml]. If you're interested, this is part of project I'll eventually put up on github with a blog post about "How to Unit Tes...

Store mousedown locations

My cocoa app calculates the location for every mousedown event. The next time the mouse is clicked, the location is overwritten by the new one. How can I store the locations? Is it possible to create an array with mousedown locations? Thanks ...

Making an array of NSRect values in mousedown method

My cocoa app calculates the location of every mousedown event. It also checks whether the location is located inside a rectangle using NSPointInRect and while enumerating over an existing mutable array with values of the rectangles. I'm using an if-statement to add the rectangle values in which the mousedown event is located to a new arr...

How can I slide a view in and out of a window in a Cocoa program.

I want to have a view on a window and in response to a message (button click or menu) I want to have another view slide down above it, and have the first view resize. I want to go from this: ********************************** * * *--------------------------------* *| |* *| ...

Why is Instruments reporting this as a memory leak?

I have some code that looks like the following: NSMutableArray *bar = [[NSMutableArray alloc] initWithCapacity:0]; NSMutableDictionary *foo = [[NSMutableDictionary alloc] initWithCapacity:0]; [foo setObject:[NSNull null] forKey:@"yay"]; [bar addObject:foo]; [foo release]; Instruments is showing that foo is leaking. I understand why t...

Simulate mouse click to window instead of screen

Is it possible in MacOS X to send a mouse click to a specific window? I already managed to send a click to the entire screen via CGPostMouseEvent. The windows i want to control overlap each other, so my next idea was to bring the proper window to the front before triggering the click. It works but ends in a total mess... ;-) ...

NSURLConnection delegate doesn't get its didReceiveAuthenticationChallenge method on server status 401

I've setup a simple NSURLConnection to query an http-server. GET /path HTTP/1.1 Host: 192.168.1.161:8282 User-Agent: NetTest1.0 CFNetwork/441.0.2 Darwin/9.6.0 Accept: */* Accept-Language: en-us Accept-Encoding: gzip, deflate Pragma: no-cache Connection: keep-alive The server responds with code 401 and the WWW-Authenticate header set ...

How do I encode "&" in a URL in an HTML attribute value?

I'd like to make a URL click able in the email app. The problem is that a parameterized URL breaks this because of "&" in the URL. The body variable below is the problem line. Both versions of "body" are incorrect. Once the email app opens, text stops at "...link:". What is needed to encode the ampersand? NSString *subject = @"This...

Cocoa API comments guideline

I'm maintaining an utility cocoa-objc framework which keeps growing. Coming from Java, I'm used to write javadoc comments for all the API I write. What are the guidelines for writing good API comments in cocoa-objc ? Is there a tool to automatically generate an API documentation like Javadoc (what is the tool used by apple for generatin...