cocoa

An NSMenuItem's view (instance of an NSView subclass) isn't highlighting on hover

I need to use a custom NSView subclass to draw some content, but it isn't drawing as highlighted when the user hovers and it doesn't dismiss the NSMenu when the user clicks on it. Any ideas? Edit So using -drawRect: and [[self enclosingMenuItem] isHighlighted] I'm able to tell whether or not I need to draw the view as highlighted and a...

Easiest way to get an NSDate representation of "the next 7am that will occur" in Cocoa?

I figure I can achieve what I want by using NSCalendar and NSDateComponents, but that would run something like the following: Get "now" Create an NSDateComponents from "now". If "now" is pre-7am, then use today's date. If "now" is post-7am, use tomorrow's date. If today is the last day of the month, increase month, set day to 1. If i...

Delete file without playing sound in Applescript ?

tell application "Finder" set deletedfile to alias "Snow Leopard:Users:test.pdf" delete deletedfile end tell The problem is I repeatedly call this script from my Cocoa application so the sound is played repeatedly too. Is it possible to disable that sound ? ...

NSInteger differences between CLI and GUI ?

I've been building a framework and writing unit tests in GHUnit. One of my Framework's accessor methods returns an NSInteger. I assert the expected value in the tests like this: GHAssertEquals(1320, request.port, @"Port number should be 1320"); When running my tests with an AppKit UI based frontend this assertion passes. However, w...

dismissPopUp is not recognized

Assuming button1 is an NSPopUpButton Assuming menu attached to button1 is displayed and being tracked. [[button1 cell] dismissPopUp] --- dismissPopUp is not recognized. Why is the dismissPopUp method not recognized? Thanks ...

How do i implement a message box in a Cocoa application?

I have implemented delete functionality in cocoa application now i want to show one meesage box when user click on delete button. ...

Cocoa: how to implement a custom NSView with an editable text area?

What's the minimum implementation needed to make a custom NSView with an editable text area? I assume NSTextFieldCell can be used for this. I've succeeded in drawing the cell in the view (which is straightforward), but making it editable seems to require a more complicated coordination between the view and the cell. Is there sample code ...

Subclassing UIButton but can't access my properties

Hi, I've created a sub class of UIButton: // // DetailButton.h #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> @interface MyDetailButton : UIButton { NSObject *annotation; } @property (nonatomic, retain) NSObject *annotation; @end // // DetailButton.m // #import "MyDetailButton.h" @implementation MyDetailButto...

Cocoa (Touch) for Swing Developers #1: Where Are the Layouts?

My iPhone SDK and Objective-C learning is moving ahead quickly, thanks to several great books and online help (including this one). But I do have some basic questions due to what I already know that will be answered eventually, but I'd rather get a heads-up now if possible :) Are there equivalents for LayoutManagers in Cocoa Touch? Ar...

NSLog(@"%@",super) crashing

I used NSLog(@"%@",super) in a method(any method) and it is crashing.... Why? How to print the super contents? Updated : currentclassname : superClassName { } and also if i use NSLog(@"%@", [super description]); It is printing "<currentclassname: 0x3db7230>" instead of superClassName... It is expected to print superClassName right. ...

NSBundle loading a NSViewController

Hey all, I'm looking into a project that would upload custom NSBundles that include a NSViewController. In my main program I've got this code to deal with the bundle after it's been loaded... id principalClass = [loadedBundle principalClass]; id instance = [[principalClass alloc] init]; [localLabel setStringValue:[instance name]]; NSVi...

Cocoa Core data: cannot save Created Items in NSTableview

Hello, I'm am a beginner in mac os x development and am trying to get started with all this. Here is my problem : I've create a non-document based cocoa app using core data as storage. I've added an entity and attributes to the xdatamodel. In IB i've created an NSArrayController and linked it properly. I've created an nstableview binde...

Download an save an image file on HDD with Cocoa

I'm building a program, and I'm quite confident using Objective-C, but I don't know how to programmatically download a file from the web and copy it on the hard drive. I started with : NSString url = @"http://spiritofpolo.com/images/logo.png"; NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]; But then I don't kn...

NotApplicable marker with display pattern

Ok, so I'm pretty new to Cocoa, especially Bindings, but here's what I'm trying to do. I've got a Core Data model consisting of two entities: Category and Item. Category has a to-many relationship to Item called children, and Item has a relationship to Category called parent. Item has two attributes that Category does not have: quantity...

Opening a streaming connection to an HTTP server on iPhone/Cocoa environment?

I've been using NSURLConnection to do a HTTP post to establish the connection. I've also implemented the didReceiveData delegate to process incoming bytes as they become available. As incoming data comes in via didReceiveData, I add the NSData to a data buffer and try parsing the bytesteam if enough data has come in to complete a messa...

Not understanding delegation in Cocoa

I don't understand the concept of delegation is used in XCode. When a new project is created, an app delegate and a view controller are created, but what does the app delegate do? How does main.m know to call the delegate? ...

external images needed by nib file

Hi, I have this nib file, with a large number of NSImageViews that use a large number of Images in my application bundle. I'm hoping to change the images displayed though while the application is running. What I want to do is to externalize these images into an application support folder so that when I want to modify them, I don't hav...

Cocoa: change cursor when it's over an NSButton

How can I change the cursor when it's over an NSButton? ...

iPhone toolbar shared by multiple views

Another iPhone noob question. The app I'm building needs to show a shared custom UIToolbar for multiple views (and their subviews) within a UITabBarController framework. The contents of the custom toolbar are the same across all the views. I'd like to be able to design the custom toolbar as a xib and handle UI events from its own cont...

Can't access UI from a delegate?

I got this code: GrooveOnDownload *dlg = [[GrooveOnDownload alloc] init]; NSURLDownload *dw = [[NSURLDownload alloc] initWithRequest:request delegate:dlg]; It starts the download in a delegate class with outlets for UI controls. But for some reason controls don't respond to direct messages from the delegate. //Header of the delegate...