cocoa

How do I call a method from an imported class in Objective C?

Hi all, I have some code which fetches an XML file from a URL and then parses it using NSXMLParser. Currently this code is contained within the viewController which calls it. I would like, for re-usability sake, to move the parsing code to an external class and call it from the viewController. I tried to achieve this as follows: Crea...

NSTextField setEnabled

I have a NSTextField object in my window which has to be disabled when a check box is clicked. I have written a IBAction to receive the check box click and disabled/enabled the text filed based on the check box state. [mName setEnabled: [mNameCheck state]]; This work fine with the basic functionality, but I found some strange behavio...

How do I send a command to a Mac via WiFi from an iPhone?

How would I send a command to a Mac (which has network sharing turned on) over the Wi-Fi network that both it and the iphone is connected to? In my case I want it to open an application. ...

NSTextView rounded border / stroke in Cocoa

Hi All I am subclassing NSTextView and over-riding the drawRect method in order to draw an NSBezierPathWithRoundedRect around the textview, however - as it has rounded edges, they interfere with the text in the text view. Is there any way to apply some kind of margin or padding all around the text input area of the NSTextView so that i...

How to use NSArrayController bound to NSUserDefaultsController with custom class

I have a NSArrayController bound to NSUserDefaultsController, and the array stores a custom class of mine, which conforms to NSCoding. It seems like I need NSArchiver, but I can't quite figure out how to glue it all together ...

OS X: how to watch socket read events with NSRunLoop?

I'm writing a Cocoa app. There is a socket in the application, and whenever the socket becomes readable I want to read data from the socket, process the data, and update the user interface accordingly. I want to integrate the read event check in the main loop, i.e. I want to attach the socket to the main loop and have the main loop call ...

Exporting data to iWork Numbers

Has anyone tried exporting data to Numbers in iWork? I want to generate a spreadsheet programmatically but I'm not having much success. I've tried unzipping a .numbers document and analysing the XML to see if I could interpret it but it's far too complicated. Also, I couldn't find the DTDs used by Apple. Judging by what's out there thi...

Autosizing boxes and positioning in Cocoa

Hi, I'm creating an application, from which a part looks like this: I all dragged them to a window in IB, but the problem is that the NSImageView, Action Buttons (Suggest, Send, Poke etc...), Information NSBox, and Friends NSTabView can all vary in height. They should always be placed below each other, with a margin of 8px. Just like...

MVC in a Cocoa document-based application

I'm going through a refactoring and reorganization of my application at the moment. I've realized that some of the separation between models and views, and their controllers has diminished and I wish to do some cleaning up. I have several key classes used in my app: NSPersistentDocument, NSWindowController, and a model class. The NSPer...

File sharing discovery in Cocoa

I'm trying to programmatically discover and then mount network volumes shared using OS X's file sharing from a Cocoa app. I'm using NSNetServiceBrowser to discover which servers are advertising file sharing - easy enough. My question is about the next step - how do you discover what shares are available for a given machine? ie. given th...

How can I disable a button while NSXMLParser runs, then enable it when it completes?

I have a viewController which imports XMLParser.h as the class xmlParser I'm passing an NSURL object in my viewController to the xmlParser class with the getXML method below goButton is the button I tap to call the getXML method below. I disable the button which I tapped to trigger the getXML method, but I'm not sure where to put the ...

easing c++ to objective-c/cocoa bridging via metaprogramming?

In a pure C++ world we can generate interfacing or glue code between different components or interfaces at compile time, using a combination of template-based compile-time and runtime-techniques (to e.g. mostly automatically marshall to/from calls using legacy types). When having to interface C++ applications with Objective-C/Cocoa fo...

Saving a 32 bit RGBA buffer into a .png file (Cocoa OSX)

I need to save the contents of a pixel editor application into a .png file but I am having trouble finding the best way to accomplish this. The pixel data is stored in a 32 bit RGBA buffer. Can anyone suggest any good tools I could use to accomplish this? EDIT: Unfortunately, CGImage and representationUsingType: are not supported by...

Universal preference pane is forced to launch on 32-bit

I'm building a Preference Pane for an application, it's Universal (PPC/32-bit/64-bit) but when I install it on the System Preferences, i'm forced to run it on 32-bit. Any idea why and how to solve it? if i run file FILE_PATH i get: FILE_PATH: Mach-O universal binary with 3 architectures FILE_PATH (for architecture x86_64): Mach-O 64...

NSThread, AsyncSocket and object deallocation

Hi! I have a piece of network code that uses AsyncSocket but moves it to a separate runloop. I'm creating this runloop with the following piece of code: [NSThread detachNewThreadSelector:@selector(_workerLoop) toTarget:self withObject:nil]; and here's how my _workerLoop looks like (they're both in the same class): -(void)_workerLoop...

What's wrong with this Objective-C threading code for my iPhone app?

This piece of code: - (IBAction) getXML { goButton.enabled = NO; [self performSelectorInBackground:@selector(parseInBackground) withObject:nil]; } - (void)parseInBackground { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; xmlParser = [[XMLParser alloc] init]; NSURL *xmlurl = [[NSURL alloc] initWithStrin...

Cocoa data hierarchy and browser

I'm trying to implement something similar to the iTunes browser, to browser a simple database of Books. I have the following entities - Author, Genre and Book. I would like to display an author list and a genre list, which act to filter the main Book list. I have tried doing this in 2 different ways - modeled as: Author ( has many ) ...

How can I convert the date string calculated by CoreData to ISO format YYYY-MM-DD HH:MM:SS +000?

I have a string like this, 285298171.84336197376251220703 and I know it's created by CoreData and I want to find a way to convert it into ISO format, can anyone help me? Thanks in advance. Added: actually this is in an XML file which an application created. 285298171.84336197376251220703 281021264.12619298696517944336 ...

Look up a volume by UUID

I know the UUID of a volume - as found in Disk Utility. How can I get additional information on the volume? Most importantly, I want to know its mount point. Looking at /etc/fstab doesn't do the trick. This does not list the root volume. I would at least need to figure out the UUID of the root volume to verify my known UUID against it...

SQLite in iPhone:I want to Retrieving 1 row for each date from sqlite

i only want to know that whether data is available for any specific date or not.If there are more than one data with the same date, i do not want to fetch all the data.I try to use LIMIT 0,1 in where clause but it means it will fetch total 1 data for the given date range. So please tell me the way to fetch data between a date range with...