objective-c

Comparing times/dates with the iphone SDK

Hi all, I am new to the whole iPhone SDK and objective C, but have managed to get three times, two pulled from RSS feed, and one from the iphone. I currently have: sunrise, sunset and current time set like: 6:51 am //Sunrise 7:36 pm //Sunset 11:34 AM //Current time I am trying to work out the best approach to find out if ...

What are best practices for error handling when writing an API for the iphone?

We are writing an API for iphone developers and we don't know what the best practice is for exception handling. We looked into NSError, standard POSIX way, NSException What is the convention that most APIs use? Which is the most "Objective-C friendly"? ...

Change appearance of toolbar from a UINavigationController

Hi there I did add a toolbar to my UINavigationController and that works as it should. But I don't see any possibility to change the appearance(like other backgroundcolor etc.) of the toolbar. The docs shows me that an UINavigationController has a toolbar property but it is readonly. Do I have to do an custom UIView or is there any ot...

How can I detect touch events on a UIImageView inside a deep hierarchy of UIViews?

I am developing a simple game on iPhone and I started with a View based application, and through the UIViewController I am loading a custom UIView that contains some more UIViews and some UIImageViews. I want to detect touch events on some of the UIImageViews, but I wasn't able so far. I've created a second project for testing purpos...

Can't connect IBOutlet in Interface Builder

Hello, I have the following code: @interface AddResident : UIViewController { IBOutlet UITextField *FirstName; IBOutlet UISegmentedControl *Gender; } I can see both of these outlets in interface builder but can only connect the UISegmented control... the other one will not connect to my UITextField on the form. Any help is ...

Issues dismissing keyboard conditionally

I have an app that has a username and password field. I want to validate the input before the the user is allowed to stop editing the field. To do that, I'm using the textFieldShouldEndEditing delegate method. If the input doesn't validate I display a UIAlertView. This approach works as advertised - the user cannot leave the field if th...

Cocoa contentsOfDirectoryAtPath: method failing with error for certain users - Mac OS X

Here's a snippet of the code: // Get into the data folder of it keychainPath = [keychainPath stringByAppendingPathComponent:@"data/default"]; DLog(@"Keychain data path: %@", keychainPath); // Define Filemanager NSFileManager *fm = [NSFileManager defaultManager]; // Catch any errors NSError *dataError = nil; // get all the files in t...

UISwitch within UIScrollview nearly impossible to use....

Hi there. I'm using a UISwitch-Component at the bottom of a view that sits within a UIScrollView. Now the problem that appeared, is that the switch is nearly impossible to swipe because the UIScrollView seems to dominate the userinput. Switching works very well by tapping the switch, but from my point of view, most users "switch" the UI...

iPhone SDK: Redirecting stderr/stdout to XCode console

I have a C library that I'm planning to use in an iPhone application. It writes a lot of its debug information to stderr. Is there an easy way to redirect stderr/stdout to my XCode console? Will I have to write wrappers that call NSLog? If so, what would be the best way of doing so? ...

Getting frequency of sound on iPhone

Hi Guys, I'm looking for an Objective-C class that allows me to get the frequency of a live input sound on the iPhone. Didn't find anything useful. Before you ask: the frequency will not change for 0.1 seconds. Thanks for answers, Christian ...

How can I compare two dates, return a number of days.

Hi, how can I compare two dates return number of days. Ex: Missing X days of the Cup. look my code. NSDateFormatter *df = [[NSDateFormatter alloc]init]; [df setDateFormat:@"d MMMM,yyyy"]; NSDate *date1 = [df dateFromString:@"11-05-2010"]; NSDate *date2 = [df dateFromString:@"11-06-2010"]; NSTimeInterval interval = [dat...

UITableView Cell IndexPath

Hello, Can anyone tell me how can I get a cell IndexPath? I was saving the IndexPath in the tableView: cellForRowAtIndexPath: method but this only loads when the cell is viewed and I need to know its index path on the viewDidLoad method. this resulted in a null value because as I said it only loads its value after the cell was viewed on...

Turning an NSImage* into a CGImageRef?

Is there an easy way to do this that works in 10.5? In 10.6 I can use nsImage CGImageForProposedRect: NULL context: NULL hints: NULL If I'm not using 1b black and white images (Like Group 4 TIFF), I can use bitmaps, but cgbitmaps seem to not like that setup... Is there a general way of doing this? I need to do this because I have an ...

Why does my UIWebView not Allow User Interaction?

Hi, I'm new to these forums so I apologize for my noobieness. I did as thorough a search as I could, but I couldn't find anyone else with this issue, applogise if this has been covered elsewhere. I've created a very simple example of my problem. I'm sure I'm missing something but I can't for the life of me figure out what. I'm creating...

How to get a volume measurement of iPhone recording in dB, with a limit of at least 120dB

Hello, I am trying to make a simple volume meter for the iPhone. I want the volume displayed in dB. When using this turorial, I am only getting measurements up to 78 dB. I've read that that is because the dBFS spectrum for 16 bit audio recordings is only 96 dB. I tried modifying this piece of code in the init funcyion: dataFormat.mSa...

Multiple Application Support Directories for iPhone Simulator?

I am developing an iPhone app with someone else. The app works fine for me, but he is running into a bug. We think this bug is related to the fact that he is getting multiple Application directories for this same app. In my ~/Library/Application Support/iPhone Simulator/User/Applications, I only have one folder at all times. He says tha...

UITableView titleForHeaderInSection prints headers to console twice then crashes

In the method below titleForHeaderInSection, for some reason the NSLog prints out the headers twice and then the app crashes in objc_msgSend. I can't understand why this would cause the app to crash? It would seem from research that crashes in objc_msgSend are caused by sending messages to already freed objects, but is that the case he...

Diference between get Object using FetchResultController and ManagedObjectContext

What's the difference between get elements from Core Data with FetchResultController or ManagedObjectContext?? 1) FetchResultController NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity:[NSEntityDescription entityForName:@"Item" inManagedObjectContext: managedObjectContext]]; NSSortDescriptor *sor...

How do I access variable values from one view controller in another?

Hello all, I have an integer variable (time) in one view controller whose value I need in another view controller. Here's the code: MediaMeterViewController // TRP - On Touch Down event, start the timer -(IBAction) startTimer { time = 0; // TRP - Start a timer timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self s...

Obj-C crashes on substringWithRange message

The following code is making my app crash at line 3 without an error I would recognize or know how to deal with. Any ideas as to what I am doing wrong? NSInteger *match = [str1 intValue] + [str2 intValue]; NSString *strrep = [NSString stringWithFormat:@"%i", match]; label.text = [strrep substringWithRange:NSMakeRange(1,3)]; ...