objective-c

Getting an NSImage from an NSProgressIndicator

I need to put the image from an NSProgressIndicator into an NSOutlineView Cell. I have written up code that does this for a determinate indicator and it works just great: NSProgressIndicator *progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 16, 16)]; [progressIndicator setStyle:NSProgressIndicatorSpinningS...

CATransition showing a single frame from the end of the transition before the animation starts

I am using some code which was originally taken from the Apple sample ViewTransitions to swap two views with each other. CATransition *animation = [CATransition animation]; [animation setDelegate:self]; [animation setType:kCATransitionFade]; [animation setDuration:0.3f]; [animation setTimingFunction:[CAMediaTimingFunction functionWithNa...

iPhone OS Utility App - Flipside View and Main View communication

I am currently working on an iPhone 2.1 application. I am new to Objective C, coming from a Java background. My application has as a base the Utility Application template available in Xcode with the iPhone SDK. Currently I have some controls, such as an UISlider and text box, in the FlipsideView. The UISlider already has a method which ...

Converting plist to binary plist

Apple strongly recommends using the binary plist format when reading large XML-based data sets into iPhone apps. Among their reasoning is the fact that XML parsing is very taxing on the iPhone. However, this requires that files residing on the remote web server be converted first. For frequently-changing content, it is not acceptable to...

Cocoa: NSURLConnection not attempting an HTTP Request

I've had significant success with NSURL, NSURL[Mutable]Request, NSURLConnection with my iPhone applications. When trying to compile a stand alone Cocoa application, 10 line program to make a simple HTTP request, there are zero compiler errors or warnings. The program compiles fine, yet the HTTP Request is never made to my web server (I'm...

What are alternatives to Objective-C for Mac programming?

I've become very comfortable in the world of pointer-free, garbage-collected programming languages. Now I have to write a small Mac component. I've been learning Objective-C, but as I confront the possibility of dangling pointers and the need to manage retain counts, I feel disheartened. I know that Objective-C now has garbage collectio...

Is it possible to program iPhone in C++

I'm all for language diversity, but Objective C is insane. So I'm curious: is it possible to code iPhone apps with C++ while using the Cocoa API, etc? ...

Cocoa/WebKit, having "window.open()" Javascipt links opening in an instance of Safari

I am building a really basic Cocoa application using WebKit, to display a Flash/Silverlight application within it. Very basic, no intentions for it to be a browser itself. So far I have been able to get it to open basic html links (<a href="..." />) in a new instance of Safari using [[NSWorkspace sharedWorkspace] openURL:[request URL...

What's the best way to find the user's Documents directory on an iPhone?

I'm reading Erica Sadun's iPhone Developer's Cookbook, and ran into a question. She says in the book that the way to find the user's Documents directory is with the code: [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; but that seems slightly brittle, and dissimiliar to the normal Mac way of doing it, which would be:...

Do I have to learn Objective-C for professional Mac Development?

Do I really have to learn Objective-C to develop solid Mac Apps? As Mac users tend to use only applications that have a nice (native) GUI, i don't think that Mono and GTK+ or any Java GUI (Swing) will fit their needs. There are projects like Cocoa#, PyObjC and RubyCocoa, but are they ready for primetime? So do I really have to learn O...

iPhone: Detecting user inactivity/idle time since last screen touch

Hi all, Has anybody implemented a feature where if the user has not touched the screen for a certain time period, you take a certain action? I'm trying to figure out the best way to do that. There's this somewhat-related method in UIApplication: [UIApplication sharedApplication].idleTimerDisabled; It'd be nice if you instead had som...

Using default tab-controller created project... first view controller doesn't respond to addsubview

I created a project using the default tab-controller project. I am using interface builder to edit the .xib file and add images and buttons. I hook them up to the FirstViewController object in interface builder (that I created and set it's class to the same as the code file). I hooked everything up using IBoutlets and IbActions. Everyt...

What is the underlying mechanism for ivar synthesis in the modern Objective C runtime

One of the features of the modern (64 bit OS X and iPhone OS) Objective C runtime is the ability for properties to dynamically synthesize ivars without explicitly declaring them in the class: @interface MyClass : NSObject { // NSString *name; unnecessary on modern runtimes } @property (retain) NSStrng *name; @end @implementation MyC...

How do I collect key input in a video-game style Cocoa app?

I'm hacking on a simple Cocoa app to make blocks move around the screen like a video game. I need to detect key presses, but I'm not going to have text entry fields like a dialog box would have. How do I get key presses without text controls? In particular, I need to get arrow keys. ...

What is good about Objective-C?

I'm a total newbie with Objective-C, and it still seems awkward to me. The mix of Smalltalk-style message passing with C-style function calls seems jarring. I'm not trying to rag on Objective-C, I really want to know what its fans like about it. Can you help this newb see the light? I'm very familiar with C++ and Python. What are ...

Updating sqlite3 API for Objective-C

I want to update/upgrade the standard Leopard install of Sqlite3 to >3.5 to use the new sqlite_xxx_v2 methods from a Cocoa project. I can't seem to find any information on how to do this. Does anyone have any tips or a site that outlines the update procedure. Also is 3.5+ supported on the iPhone. I understand it's embedded so shouldn'...

How to programmatically generate a PDF from any document on OSX?

I'm working on a project for OSX where the user can pick a collection of documents (from any application) which I need to generate PDF's from. The standard Macintosh Print dialog has a PDF button which has a number of PDF-related commands including "Save as PDF...". However, I need to generate the PDF file without requiring user interac...

Remove HTML Tags from an NSString on the iPhone

There are a couple of different ways to remove HTML tags from an NSString in Cocoa. One way is to render the string into an NSAttributedString and then grab the rendered text. Another way is to use NSXMLDocument's -objectByApplyingXSLTString method to apply an XSLT transform that does it. Unfortunately, the iPhone doesn't support NSAt...

Initializing a class using superclass initializer

Hello! I have got two classes, one a subclass of the other (say Animal and Dog). The superclass has got some initializers (say initAnimal), the subclass has some initializers (say initDog). The problem is that it is perfecly legal (from the compiler’s viewpoint) to do something like Dog *adog = [[Dog alloc] initAnimal], ie. initialize a ...

Can you use NSPasteBoard to paste into another application?

Hi, I found out how to get the content of the NSPasteboard, and to copy it into my active application. I haven't found a way to paste it into another application, just how to paste it into my current application. If you're wondering why I would want to do this, I'm researching if there is a way to improve Jumpcut open source applicatio...