cocoa

Accessibility API - Setting keyboard focus to a specific element

Using the accessibility API, I am drilling down through a series of elements and finding a specific AXUIElementRef I am interested in (all in an external application). How do I check if this element currently has keyboard focus? And if not, how do I set it? Something similar to using AXUIElementSetAttributeValue to set the kAXMainAttr...

Why is there no NSHTTPURLProtocol class?

Well, NSURLProtocol is pretty generic right? It is for defining all kinds of protocols, isn't it? So why is there nothing like NSHTTPURLProtocol? Instead, there is an informal category on NSURLRequest with specific HTTP stuff. Why did they do that this way? Why no custom HTTP protocol instead? What's the idea behind putting all this st...

Reading and outputting UTF-8 strings in c/cocoa

In an objective-c/cocoa app, I am using c functions to open a text file, read it line-by-line and use some lines in a third-party function. In psuedo-code: char *line = fgets(aFile); library_function(line); // This function calls for a utf-8 encoded char * string This works fine until the input file contains special characters (such ...

With Cocoa how do i check that given file is owned by current user?

Given a file path how do i check that this file is owned by current user? Currently i managed to get: [[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:outError] fileOwnerAccountID]; Which return NSNumber*. But i can't seem to google for how to get current user account id to compare it with. Besides all this looks...

NSXMLParser Memory Allocation Efficiency for the iPhone

Hello, I've recently been playing with code for an iPhone app to parse XML. Sticking to Cocoa, I decided to go with the NSXMLParser class. The app will be responsible for parsing 10,000+ "computers", all which contain 6 other strings of information. For my test, I've verified that the XML is around 900k-1MB in size. My data model is to...

Replacing one colour with another in an NSImage

I have an NSImage and want to replace one color in it with another (e.g. replace all the blue with a green colour) Is there an easy way to do this and if not, how could I get this functionality? ...

hardware acceleration / performance and linkage of different macosx graphics apis, frameworks and layers

the more i read about the different type of views/context/rendering backends, the more i get confused. regarding to http://en.wikipedia.org/wiki/Quartz_%28graphics_layer%29 MacOSX offers Quartz (Extreme) as a render-backend which itself is part of Core Graphics. in the Apple docs and in some books too they say that in any case somehow y...

Formats for communicating between backend and Objective-C/Cocoa

I'm developing an iPhone app that is connected to a backend server. It needs to communicate with it many times, through several requests. I'm sending HTTP messages, but I want to receive more complex responses that I can parse somehow. Supposedly, I can provide any type of format for responses from the server, so my question is: which on...

NSURL's parameterString confusion with use of ';' vs '&'

I'd like to use NSURL's parameterString method to parse out the parameters of a URL I've been passed. It says URL must conform to RFC 1808 but now wondering if ours do?!? We use something like: http://server/path/query?property1=value1&property2=value2 but RFC 1808 never mentions the ampersand (&) as a valid parameter separator (...

What are the best web site to learn cocoa at the beginner level ?

HI all, Can any body tell me which web site is the best to learn cocoa development at the beginner level for the desktop and windows applications. direct link to those web site will be help ful. Thanks . ...

How does Cappuccino manages to layout views like in Cocoa?

How does the layout support of Cappuccino work? For example the centering and the automatik resizing. ...

MallocDebug "Unable to read malloc information from (null)"

I have a certain .app built in xcode (version 3.2.1) as a Release build. I open MallocDebug and browse to the build directory, selecting the Release build and clicking the .app file. I then hit "Launch". MallocDebug then seems to freeze, giving me the spinning beachball for a minute or so, followed by the error message: Read Data "Un...

Using sudo commands in Cocoa and Objective-C?

What is the proper way to run something like $sudo touch folder_name or $sudo rm from within Objective-C/Cocoa? I'm changing and moving around a few files and need elevated privileges. Any code sample would be greatly appreciated. Thanks. ...

NSTimer within NSThread Memory grows ?

I am using a timer within a thread , i am instantiating the timer all the time however when i run the application within instrument i see the memory grows exponentially, i am not having any leaks. I am sure that NSThread is causing the growth ? . I am stopping the current timer before running a new one (singleton) and i am releasing eve...

Convert const char* string to NSString with length AND encoding

I wonder which method would be better to convert const char* string to NSString. I found there are some facts. [NSString stringWithCString:length:] is kind of deprecated. [NSString stringWithCString:encoding] may be used for my purpose But I want to convert with length AND encoding(because I want to make that fine if I have some Non-...

Call instance method from class method

Hi dudes, and dudetts! So I need to call some instance methods from class methods in objecitve-c... Example : +(id)barWithFoo:(NSFoo *) { [self foo]; //Raises compiler warning. } -(void)foo { //cool stuff } So my question; StackOverFlow is how do you do such things in Objective-C, I'm new kinda to OOP, so am I mad, or is there a ...

How to add popup menu on NSToolbar item ?

I've tried to add NSPopupButton + CustomView, but it's not what I wanted. I would like to mimic "Tasks" on Xcode's toolbar. Thanks in advance ...

Cannot strip newline from Cocoa NSMutableString ...

Hey, for the life of me, this is not working:.. NSMutableString *b64String = [[[NSMutableString alloc] initWithFormat:@"Basic %@", [string _base64Encoding:string]] autorelease]; [b64String stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; NSLog(@"(%@)", b64String); NSRange foundRange = [b64String r...

Unfamiliar with technique to solve pre-populating textfields (w/out access to a viewDidLoad or similar method) on Mac Desktop

Hey, I have a mainMenu.xib - that sets up all my interface items (button, textfields, etc). I have a LogController that has access to all these items via IBOutlet and IBAction. Works fine - All connected and running well. However, I want to have NSUserDefault values pre-populated in the textfields. However, I can't figure out how - si...

Testing if an application can open a specific type?

On Mac OS X, how can I tell if a given application opens a specific type? I have two UTIs that I'm interested in: public.text and public.image and I have a list of applications. I want to filter the list by those two types so I have a list of text viewers and a list of image viewers. I've seen a related question on SO where it's possib...