objective-c

How should I construct an NSDictionary with multiple keys?

I have a situation where I want to map a pair of objects to a dictionary of information. I'd like to avoid creating an NSDictionary of NSDictionaries of NSDictionaries since that's simply confusing and difficult to maintain. For instance if I have two classes, Foo and Bar, I want {Foo, Bar} -> {NSDictionary} Are there other options th...

Quick Multiplication Question - Cocoa

Hi there, I'm still learning, and I'm just stuck. I want the user to enter any number and in result, my program will do this equation: x = 5*y (y is the number the user adds, x is outcome) How would I do this? I'm not sure if I'm suppose to add in an int or NSString. Which should I use, and should I enter anything in the header file...

Comparing colors in Objective-C

Hi! I'm trying to determine if two colors are equivalent, using code written in Objective-C. I'm using this snippet of code to determine if the two colors are equivalent (currently for debugging purposes) NSLog(@"currentColor is %@", currentColor); NSLog(@"Adjacent Color is %@",[[buttonArray objectAtIndex:1] backgroundColor]); NSLo...

How to extract pure string from a constant string

When I print the value of a CFString constant e.g. an AddressBook label in the console, the output value is _$!<home>!$_. How do I extract only the pure value, e.g home? ANy help would be greatly appreciated please. ...

Creating a button on a View from a second View

Hi, I have this app I'm working on, which on a second view asks (textfield) the name for a button to be created on first view. After specifying the name and pressing OK button, the first view pops up (as demanded) but there's no new button, although created indeed. Can I use the following code in a second view method, to "refresh" the f...

Cocoa - Add Video Watermark General Info

Just looking for how to programmatically add a watermark or some sort of overlay to video using cocoa. Not looking for a step by step ( although that would awesome ), but more or less looking for where I should start looking to learn how. Are there frameworks developed to work for this. Would like something native to cocoa or objectiv...

Trying to copy a string into a textfield in objective-C

I am having trouble copying the value of an NSString into a Textfield value. I've done this before, but for some reason it's not working in the function below. Can someone tell me if I'm doing something wrong? pictureComment is the Textfield and comment is an NSString. When I look at the log file, only 'comment' prints. Any suggestion...

Action sheet not opaque

For some reason the top half of the my action sheet is not opaque. I have created the view and action sheet using the code below: //allocate the view self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:nil delegate:self ...

Learning the basics of UIScrollView

I've been having a very hard time finding good examples of UIScrollView. Even Apple's UIScrollView Suite I find a bit lacking. I'm looking for a tutorial or example set that shows me how to create something similar to the iPhone Safari tab scrolling, when you zoom out from one browser window and can flick to others. But I'm having a ha...

UITableView corruption upon scroll.

Hello all, Im trying to get a UITableView to display items contained within an array. This array is contained within a class (HX_ParkingSearch). I have a ref to this class that contains the array inside the app delegate class, to enable the views to access it. Problem is that I get one page of results displaying correctly inside the tab...

How to show ipod controls?

When user double-tap home button, the ipod controls shows on the screen. I want to allow user show ipod controls by tapping custom button in my application. Is any possibility to do it? Sorry for my english. ...

Casting in objective-c

I have a dictionary object that I am pulling data out of. The field is supposed to be a string field but sometime all that it contains is a number. I get the info using: NSString *post = [[temp objectAtIndex:i] valueForKey:@"POSTDESCRIPTION"]; So it is going into a string object. However, when I try to assign that to a cell's text via...

How to identify & use OSType in Cocoa

In Cocoa/Mac OSX 10.6 OSType IOSurfaceGetPixelFormat(IOSurfaceRef buffer) returns a type OSType where can I find some documentation/reference on the supported OSType with regard to the context of this function. What sort OSType should I expect with IOSurfaceGetPixelFormat? do you have any ideas on the various expected values from t...

Need help understanding "kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid Region"

While running my application (which does a good bit of custom drawing) I get this error (it happens a good bit with no observable side effects, but I'd like to understand what's happening). <Error>: kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch ...

Need help with IPhone Address book CPRecordGetStore error

I get the following error in my IPhone crash report. I cant work out why it happens...is it possible to try and catch an EXC_BAD_ACCESS? Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000008 Crashed Thread: 0 Thread 0 Crashed: 0 AppSupport 0x304a17d8 CPRecordGetStore 1 ...

NSArray atomfeed and categories

Hi, I have an atomfeed with which is succesfully getting parsed. All the articles are in the root array. But now I also have categories as a tag in the feed. How can I parse the atom xml so that the root array contains the categories and each category filters to an array with the corresponding articles. Thanks, Bing ...

CGEventTimestamp to NSDate

I'm simply trying to convert a CGEventTimestamp (which is an unsigned 64-bit integer roughly representing nanoseconds since system startup) into an NSDate. I know there's a way to convert "time since system startup" into either an NSTimeInterval or a date relative to a reference date, but I'm not finding it. How do I convert a CGEventTi...

iPhone, C/objC: getting hostname (not by resolving from IP) by hooking into system wide functions?

I'm currently writing an MobileSubstrate plugin (code injection for iPhone). It gets the hostname by hooking into connect() and this piece of code: #ifndef NI_MAXHOST #define NI_MAXHOST 1025 #endif int error; char hostname[NI_MAXHOST] = ""; error = getnameinfo(serv_addr, addrlen, hostname, NI_MAXHOST, NULL, 0, 0); if (error ...

How can you tell if a directory is writeable in Objective-C?

I want to use an open panel to let the user select a destination, but I want to alert them at that point that point that the directory is not-writable. I generally prefer to create it and handle the error, but that's not useful to me here, since I don't want to create the folder just yet. (I'll be sure to handle the error when I do creat...

How can I set rich text properties on a UITableView footer?

Guys- I am using - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { if ( section == 0 ) { return NSLocalizedString(@"Section_0_text", @""); } if ( section == 1 ) { return NSLocalizedString(@"Section_1_text",""); } return nil; } Can I modify return string text font, co...