objective-c

How to call an Objective-C method from Javascript in a Cocoa/WebKit app?

I have a Cocoa app that uses a WebView to display an HTML interface. How would I go about calling an Objective-C method from a Javascript function within the HTML interface? ...

How can you generate a Makefile from an Xcode project?

I want to generate a Makefile from an existing Xcode project on the Mac. Specifically, an existing iPhone, Objective-C program on the Mac. I found PBToMake, but it looks like it is for Xcode 2.1 and when I tried using it, it did not work for an Xcode 3.1 project. ...

What is a better way to create a game loop on the iPhone other than using NSTimer?

I am programming a game on the iPhone. I am currently using NSTimer to trigger my game update/render. The problem with this is that (after profiling) I appear to lose a lot of time between updates/renders and this seems to be mostly to do with the time interval that I plug into NSTimer. So my question is what is the best alternative...

Is there any way to get access to the DOM from Objective-C when using UIWebView?

UIWebView is fine for displaying HTML, but I'd like to modify the loaded DOM from my Objective-C program. Does anybody know how to do that? This is a third party page, so I can't really include any custom JS to do so...unless I can modify the DOM somehow. ...

how to check if a folder exists in objc?

How to check if a folder exists in objective-c? ...

How do I flip a sprite/texture in OpenGLES?

I have a sprite loaded as a texture and I need to animate it, allowing it to "face" left or right -- essentially sometimes I need to "flip" it. I know that OpenGL has a gltranslate which repositions an object, and glrotate which rotates it. Is there a method that simply flips it across one axis? If not, how would you accomplish this...

iPhone programming - impressions, opinions?

I've been programming in C,C++,C# and a few other languages for many years, mainly for Windows and Linux but also embedded platforms. Recently started to do some iPhone programming as a side project so I'm using Apple platforms for the first time since my Apple II days. I'm wondering what other developers that are coming to Mac OSX, Xcod...

How do I create a zoom effect in OpenGLES on the iPhone?

I have an OpenGL ES game that I am hacking together. One part of it involves looking at a large "map-like" area and then double-tapping on one part to "zoom into" it. How would you use OpenGL ES to provide this effect (given that it may need to zoom in on different parts of the map). I've heard of glScale and glOrtho, but I'm uncl...

Objective-C switch using objects?

I'm doing some Objective-C programming that involves parsing an NSXmlDocument and populating an objects properties from the result. First version looked like this: if([elementName compare:@"companyName"] == 0) [character setCorporationName:currentElementText]; else if([elementName compare:@"corporationID"] == 0) [character setCo...

Memory Management in Objective-C

I come from a C/C++ background and the dynamic nature of ObjectiveC is somewhat foreign to me, is there a good resource anyone can point me to for some basic memory management techniques in ObjectiveC? ex. retaining, releasing, autoreleasing For instance, is it completely illegal to use a pointer to an Objective C object and treat it as...

What is the easiest way for a non-programmer to learn the basics of iPhone App creation?

I'm primarily a designer, with a fairly high level of understanding of CSS and HTML. I have an idea for a very simple iPhone app, largely involving a timer, an animated graphic, and some sound. If I get more advanced there could be some simple customization settings I have no understanding of Objective C, or C of any kind for that matt...

Which to go with long term - C, Objective C, or C++?

One thing I've really been meaning to get back into is C++ programming but I am not sure if I should go back to C++ (which I have some basic console programming knowledge) or should I look into C or Objective C? I'm looking at the long term as well as ease of coding such as good editors, compilers, etc as well as which would be the quick...

filtering NSArray into a new NSArray in objective-c

I have an NSArray and I'd like to create a new NSArray with objects from the original array that meet certain criteria. The criteria is decided by a function that returns a BOOL. I can create an NSMutableArray, iterate through the source array and copy over the objects that the filter function accepts and then create an immutable versio...

How can I automatically add properties in Objective-C?

When adding new properties to classes, I find myself typing the same things over and over in xcode: add TYPE *NAME; (in .h interface) add @property (nonatomic, retain) TYPE *NAME; (in .h) add @synthesize NAME; (in .m) add [NAME release]; (in .m dealloc) (I'm in a non-garbage collected environment.) How can I do this automatically? ...

Lots of unnecessary frameworks load into my iPhone app - can I prevent this?

There appear to be a lot of unnecessary frameworks loading into my iPhone app. I didn't link against them in Xcode, and I don't need them. When I run "lsof -p" against them on the iPhone, I see these (and others) that I can't explain: CoreVideo AddressBookUI JavaScriptCore MobileSync EAP8021X BluetoothManager MusicLibrary CoreAudio ...

Best way to remove from NSMutableArray while iterating?

In Cocoa, if I want to loop through an NSMutableArray and remove multiple objects that fit a certain criteria, what's the best way to do this without restarting the loop each time I remove an object? Thanks, Edit: Just to clarify - I was looking for the best way, e.g. something more elegant than manually updating the index I'm at. For ...

How can I dynamically create a selector at runtime with Objective-C?

I know how to create a SEL at compile time using @selector(MyMethodName:) but what I want to do is create a selector dynamically from an NSString. Is this even possible? What I can do: SEL selector = @selector(doWork:); [myobj respondsToSelector:selector]; What I want to do: (pseudo code, this obviously doesn't work) SEL selector = ...

What are the advantages of using Objective-C over C++

I have heard mention of Objective-C but I have never used it myself. I was curious what everyones opinion of it was in general and also in relation to C++. Are there any types of projects where it would be more useful or less useful? ...

How to view contents of NSDictionary variable in Xcode debugger?

Is there a way to view the key/value pairs of a NSDictionary variable through the Xcode debugger? Here's the extent of information when it is fully expanded in the variable window: Variable Value Summary jsonDict 0x45c540 4 key/value pairs NSObject {...} isa 0xa06e0720 I was expecting it to show me each element of the...

setPrimitiveValue:forKey: and to-many relationships

Apple's documentation on -setPrimitiveValue:forKey: is vague in two ways when using it to manage to-many relationships. First they state: If you try to set a to-many relationship to a new NSMutableSet object, it will (eventually) fail. Eventually?! What does that even mean? Will it fail later during -[NSManagedObjectContext save:]...