cocoa

resolution from a PDFPage?

I have a PDF document that is created by creating NSImages with size in 72dpi pts, each has a single representation which is measured in pixels. I then put these images into PDFPages with initWithImage, and then save the document. When I open the document, I need the resolution of the original image. However, all of the rectangles that ...

In Cocoa, how can my NSView receive an event when the mouse is held down (but not moved)?

I'm looking for the right way to handle "mouse held down in one spot" events in my NSView subclass. I am familiar with Cocoa's mouseDragged: event, but it is only triggered when the mouse moves. If the mouse stays in the same position, no drag event is triggered. Similarly, mouseDown: is only fired when the button is first pressed. My v...

Access Cocoa and/or Carbon to automatically start on boot on OS X (on C++ also using QT)

I have a C++ application using the QT framework. I'm trying to add an option for the user to be able to set the program to start automatically on startup. My development machine is running OS X 10.6. As my main Mac reference, I'm using this Apple documentation. According to the documentation, there are two recommended ways of doing thi...

Is NSURL supposed to parse invalid URLs?

I could not really find this in the documentation ... I'm writing some unit tests and one of the tests that is supposed to fail is [NSURL URLWithString: @"cow"]. Because cow is not a valid URL. However, it is happily parsed by NSURL with no errors at all. It does not return nil and it does not throw an exception. Calling [url absoluteS...

iPhone memory leak help

I'm new to iPhone development, and I've just run my iPhone app throught the Intruments Leaks tool for the first time, and discovered a leak with my ListViewController dataArray method. When I click on the listing it shows the code, and a few lines have percentages next to them. Presumably they're the lines that are leaking memory. I've ...

life time of objects in NSMutableArray

There are two classes, let's call them Class A and Class B. Also, in class B, there's a NSMutableArray called arrayB. @interface A { // for reference functions in B B *obj; } @property (assign) B *obj; - (void) addObject: (id) objectB; And I access B by calling: obj = [[B alloc] init]; Here's definition of B: @interface B...

How to auto-crop a CIImage?

I've got a CIImage with an alpha channel. Big portions of it are fully transparent. I'd like to find the minimal axis-aligned bounding box containing the full nonzero-alpha region, and crop the image to this bounding box. Similar to the "auto-crop" feature in GIMP. How should I proceed? ...

reimplementing NSObject from scratch

When I was reading about the new 4.0.2 iOS update I wanted to know what hackers do or try doing with a buffer overflow, which after some wikipedia'ing got me interested in playing with malloc and thus creating my own "NSObject". I am not actually planning to use this in any of my applications, its only for learning and playing around wi...

No MouseUp:/Down: on custom view in NSSplitView on Leopard

I am currently working on a project build for OSX 10.5 and up. First of all, the 10.6 users do not see this; only 10.5 users have this issue. You are not able to reproduce this on 10.6. In short: when placing an custom extended class of NSView with an overload implementation of - (void)mouseUp:(NSEvent *)theEvent the mouseUp doesn't get...

How do I pass an object into a delegate?

I am creating a delegate view controller and presenting it to the user to perform an action but I would like to change a NSString on the delegate view controller based on the originating view controller. For example if the delegate view controller is a delegate of viewControllerA, then display Foo, but if its a delegate of viewControlle...

Relationship between AppDelegate and main.m

Ok, I'm totally new to obj-c + cocoa, so this is probably obvious, but here goes: I've been moving from command line apps to cocoa apps in learning how to work with objective-c in Xcode. One thing I don't really understand is the role of the AppDelegate and how it connects to main.m It seems like you could put your entire program in th...

Cocoa WebView, WebKit - Prevent I-Beam cursor from showing over text?

Hi all, Cocoa app, SnowLeopard I have a WebView in to which I'm loading HTML (essentially for application UI purposes). In the html, I've added: <body onselectstart="return false" ondragstart="return false"> This prevents text from being selected, which is what I want for this job. However, whenever the cursor is moved over any te...

Accepted Method for Retrying URL Request in Objective-C?

I have a connection request working using the stringWithContentsOfURL:encoding:error: method from NSString. I want to be able to retry the connection if it fails the first time. I was going to rewrite the function to use the timeout functionality of NSURLRequest, but I think I'd really like to use multiple retries before failing out. As...

Centering an NSRect with code..

Hey all, I have a project that I am working on and I have noticed that my NSRect that I draw at a certain x, y coordinate that would be the center for the resolution I am working on, is not the center if the resolution changes. I understand how it all works. The Issue is that my project is going to be displayed on multiple resolutions ...

Cllocation stops update when movement has stopped

After switching to SDK4 Cllocation updates behave strange. Before, the delegate was calles twice or sometimes even 3 times a second if the signal was good. It didn't matter if we were moving or if the movement stopped. Now, the delegate stops to be called as soon as the movement stops. There might be one or two more calls but thats it. ...

what's the difference between "bundle display name" and "bundle name" in cocoa application's info plist

here is a good question but I just wonder the difference between "bundle display name" and "bundle name" in cocoa application's info plist. ...

How to reverse a [NSWindow zoom] method call?

Maybe i'm just too blind to RTFM but what is the method to call to reverse the zoom (maximizing of a window) and bring the window back into the old state. ...

[Cocoa] Is it possible to change the Dock icon of an app so it remains when it is not running?

Is it possible to badge a dock icon and have the icon persist when the application is quit? iCal does this, but I have not seen it anywhere else. ...

Proper construction of NSFastEnumeration class

I am definitely a beginner when it comes to Objective-C! Any help would be hugely appreciated. This code works for me, but I really feel like it will certainly blow up on me in the future. For example, what if someone calls autorelease drain in the middle of a for loop. Also, what the heck is the difference between itemPtr and stackbuf?...

NSURLRequest cannot handle HTTP body when method is not POST?

Whenever I set a body on a mutable request with the method set to anything other than POST, the body is not included in the request and I get a kCFErrorDomainCFNetwork error 303 (kCFErrorHTTPParseFailure) when the server replies. Changing the method to POST is all it takes for the request to go through with no error. Is there any way to ...