objective-c

Getting Numbers From A CFDictionary For Use In Calculations, iPhone

Hello all, I found this in my travels: http://www.opensource.apple.com/source/IOKitUser/IOKitUser-502/ps.subproj/IOPSKeys.h How would I get the values (as a number) of: #define kIOPSMaxCapacityKey "Max Capacity" and #define kIOPSDesignCapacityKey "DesignCapacity" I want to be able to use them throughout my app. What do I need to...

Glib use in an iPhone App

Hi, I would like to develop an iPhone App based on an existing open-source Objective-C framework, however that framework makes extensive use of the glib library and I cannot find a way to build and include the glib library for an iPhone app (non jailbreak). Is there any way this can be done, or is there any recommended approach to port...

What is the fastest routine to convert NSArrays to C-style (double) arrays?

Hi all, I have 2 NSArray (Mutable, actually) that I am trying to convert to a C-style double array for a c routine i am passing them to. Here is my Objective-C routine: NSMutableDictionary *childDictionary = [myParentDictionary objectForKey:resort_code]; latitudeArray = [childDictionary objectForKey:@"lat"]; longitudeArray = [childDic...

NSURL pull out a single value for a key in a parameter string

Hi, I have an NSURL: serverCall?x=a&y=b&z=c What is the quickest and most efficient way to get the value of y? Thanks ...

How to do multiple interfaces in Objective C?

How can I do the following things in Objective C (the examples below are in pseudo-code): interface A extends B, C interface A interface B class X inplemements A, B 3. interface A class X implements A class Y implements A interface B class Z extends Y implements B thanks! ...

Custom UIView subclass as a UIViewController property.

Hello. I had thought I actually had a pretty good handle on the whole view controller model, but something just doesn't seem to making much sense for me. My main issue is with adding a custom UIView subclass as a property of a UIViewController subclass. Whenever I assign a valid instance of a UIView subclass to that property, nothing h...

iPhone SDK: verify XML before processing it?

Is there a way to verify / validate a remote XML (or download it first and store it locally) before processing it and store the info into CoreData or DB with iPhone SDK 3? ...

NSDateComponents - EXC_BAD_ACCESS error

Basic question to which I'm sure there is a simple answer. I'm trying to get the timestamp of a photo. When I try to access the NSDateComponents to retrieve a specific date element (say "day" for example), I get a EXC_BAD_ACCESS error. First, the relevant bits of my code: // formattedDateString is a string representing the "DateTimeO...

How to delete ALL FILES in a specified directory on the app?

Given a directory [[self documentsDirectory] stringByAppendingPathComponent:@"Photos/"] how do I delete ALL FILES in this folder? (assume a correct documents directory path) ...

Core data object comparison

Is there an easy/generic way to compare two objects to see if they are the same? By 'same' I mean identical entity name, all attributes and relationships are the same, but the internal object ID is different. Similarly, is there an easy/generic way to find the differences? ...

how to instantiate an object of class from string in Objective-C?

hello, I've a String who's value is the name of the Class[MyClass] which has to be instantiated, and MyClass has a method called -(void)FunctionInClass; i'm using the method called NSClassFromString to instantiate MyClass.I want to know 1) what does NSClassFromString return?? 2) what is id? 3) How to call method -(void)Functioni...

GUI-less App Bundle

I would like to create a helper application that has no GUI yet does have access to an app bundle. I was looking at the Xcode command line project templates, but these all just generate executable files. How can I create something like a command line tool that presents no application menu yet provides access to bundle resources in a .app...

NSButton state != 0 when alloc'd

I have two projects that include the same code: NSButton *button = [[NSButton alloc] initWithFrame:ctrlRect]; (gdb) print (int)[button state] $1 = 1 in the other project $1 = 0 I am compiling both with GCC 4.2, 10.6 - no other apparent differences in compiler settings. If I alloc/init an NSButton earlier in the app, state = 0 wh...

Open panel appears then disappears immediately

Hi, I am using this code: NSOpenPanel *openPanel = [NSOpenPanel openPanel]; [openPanel beginForDirectory:nil file:nil types:[NSImage imageFileTypes] modelessDelegate:self didEndSelector:NULL contextInfo:NULL]; This is the only code in the method. When the method is called, the open panel appears on-screen for a second then di...

Can I separate C++ main function and classes from Objective-C and/or C routines at compile and link?

I have a small C++ application which I imported Objective-C classes. It works as Objective-C++ files, .mm, but any C++ file that includes a header which may end up including some Objective-C header must be renamed to a .mm extension for the proper GCC drivers. Is there a way to write either a purely C++ wrapper for Objective-C classes ...

NSClassFromString returns nil

Why does NSClassFromString return nil ? As per the definition it has to return class name. How should i take care to rectify this problem. since i need to instantiate a class from string and call the method which is in the class using the instance created. This is how my code looks like. id myclass = [[NSClassFromString(@"Class_from_St...

What is the best way to make a UIButton checkbox?

I am trying to make a standard check box for my iPhone app from a UIButton with a title and image. The button image changes between an "unchecked" image and a "checked" image. At first I tried subclassing UIButton but UIButton has no -init*** method to use in my -init method. What is the best way to do this? Thanks in advance. ...

How to update NSMutableDictionary ?

I have an NSMutableDictionary. NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; I have to update an element in that dictionary. How i can do that ? Thanks in advance ...

Issue DSI Commands (NSURLConnection?)

How would I issue DSI Commands on iPhone? DSI Commands are used to communicate with an AFP server over TCP. http://en.wikipedia.org/wiki/Data_Stream_Interface Is this something that can be done via NSURLConnection? Thanks! ...

How can I store an image in the iPhone device file system so that later if I want I can retrive it and use in my app?

Hi All, I am trying to store an image in the device through my program. I am able to store the image in the sandbox. After quitting the app when I run it again the address of the sandbox changes so I am not able to retrive it and use it in the next run. Please help. Thank You All. ...