objective-c

Hide Input Keyboard on iPhone Without Knowing First Responder?

I have seen this question, but the question is how to know which textView is the first responder? This question looked promising to figure out the first responder, but it turns out that it calls private APIs. Is there any way to hide the keyboard or to figure out the first responder as the-one-who-has-the-keyboard? ...

iPhone app UI element

http://culturedcode.com/things/ do you guys know what UI element they used for their the top menu (home, car, phone...), the "A magical tag bar"? or is it a custom made UI? If so how do I make one that look like that? ...

How to properly invalidate an NSTimer

I've got an iPhone app with an NSTimer called pressTimer that goes off every time someone touches this button. The problem is they touch the button a lot, and I want the timer to stop when they lift up their finger. So I declared pressTimer in my .h and synthesized it in .m then assigned and started it on the TouchDown action I created. ...

Cocoa method to return a list of all letters in the current locale's alphabet?

I'm currently trying to implement a UITableView with a delegate and data source that replicates, as closely as possible, the functionality found the ABAddressBookUI framework's ABPeoplePickerNavigationController class, but with the added ability to select multiple contacts at once (as indicated by adding/removing an accessory view to the...

Prefix.pch error in Xcode

I get the following error in Xcode, when building project. Can someone help me fix it? #ifdef __OBJC__ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #endif with this error: Prefix.pch:6:38: error: Foundation/Foundation.h: No such file or directory Prefix.pch:7:28: error: UIKit/UIKit.h: No such file or directory ...

EXC_BAD_ACCESS On reading and writing to plist files.

I'm getting tonnes of EXC_BAD_ACCESS errors related to the following two functions for reading and writing to plist files. I think its memory related. Any suggestions? +(NSString *) getSettingString: (NSString *)key defaultValue:(NSString *)defValue { NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUs...

http file upload Objective C

I'm trying to upload an image file to a http server. Here's the code fragment NSData *imgData = UIImagePNGRepresentation(img); NSString *post = [NSString stringWithFormat:@"&UserID=%@&Query=%@&fileContent=", userID, @"putImage"]; NSMutableData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; [p...

how to set UIPickerView's current selection.

I have a picker View in one xib file, and a map View in another. The user selects a map view with the picker View, and the clicks a button, which loads the mapView. However, when I return to the picker View xib file, the picker View goes back to the default selection. How do I make the picker view automatically select the mapView that th...

'NSString' may not respond to '-hexIntValue' warning, function works fine

I'm taking a hex color value received as a string and converting it to an int so that I can get the proper hex values. I have the following code underneath my imports: @implementation NSString (HexIntValue) - (unsigned int)hexIntValue { NSScanner *scanner; unsigned int result; scanner = [NSScanner scannerWithString: self...

How to get center of an MKMapView map?

I have an MKMapView which allows the user to scroll the map around. Later, I want to get the latitude and longitude of the point at the center of the map, but can't find an easy way to do it. At the moment I'm trying something like: CLLocationCoordinate2D centre = [locationMap convertPoint:locationMap.center toCoordinateFromView:locatio...

How to create UIIMage from Hex Data?

Hi, I am using XMPP and XMPP will give me a photo data like the following: a3f549fa9705e7ead2905de0b6a804227ecdd404 So I assume the above data is the photo data and I assume that it's Hex data. (maybe I am wrong) So I use the following to create the UIImage, but it doesn't work anyone know how to do it? What I am trying to do is to ch...

Using selectors for callbacks?

hi, I think i should be using selectors (or even a different paradigm), but even after R'ing TFM I can't figure out what i'm supposed to do. It's all related to callbacks from a delegate I have my main Model object: @implementation Model @synthesize myConnection; // which is an NSURLConnection ... -(void)someMethod{ ...

What is wrong with my do/while loop?

the following code gives me an error of: "expected ';' before '{' token". can anyone see why? do { r = rand() % numElements; } while ([questionsShown containsObject:r] && myCount < numElements) { //code here… } ...

Deprecated constant in iOS

I building an app targeting iOS 3.1.3 and later and I've run into a problem with UIKeyboardBoundsUserInfoKey. Turns out it is deprecated in iOS 3.2 and later. What I did was use the following code to use the right key depending on the iOS version: if ([[[UIDevice currentDevice] systemVersion] compare:@"3.2" options:NSNumericSearch] != N...

Error trying to get iAds off screen

Trying to make iAds go off screen when no ad is loaded, as per Apple's request. They gave me this code: - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error { if (self.bannerIsVisible) { [UIView beginAnimations:@"animateAdBannerOff" context:NULL]; // assumes the banner view is at the top of the s...

How to insert some data into a string of AppleScript

I have a function that sends a string "theData". I want to insert that string here in this code. Would someone please tell me the correct syntax for this? Things get a bit hairy with the \"s and the "s. Thanks! NSTask *task; task = [[NSTask alloc] init]; [task setLaunchPath:@"/usr/bin/osascript"]; [task setArguments:[NSArray arrayWi...

EXC_BAD_ACCESS Error for no conceivable reason.

OK, This is a method from my program that keeps giving the EXC_BAD_ACCESS error and crashing. I indicated the line below. questionsShown is a readwrite property and points to an NSMutableArray that I initialize with a capacity of 99 at an earlier point in the program. When I debug everything appears normal in terms of the property being ...

How can I automatically click cancel when an OK-Cancel alert pops up in the UIWebView?

I'm having a problem with my UIWebView for my iPhone App... I am getting an alert thrown up with OK-Cancel button options, and I don't want the user to see this... But the web page automatically pops up an alert. How can I programmatically detect the Alert was thrown up and how do I click the cancel button on the alert? Thanks, Matt ...

Dismissing multiple modal views

My application presents a modal view (A) from the main view that lets the user make a selection. When they make that selection it opens a second modal view (B) on top of the first one (A). When I'm done with the second modal view (B), and want to dismiss it, I would like to dismiss the first one (A) and the second one (B) at the same ti...

MBProgressHUD causes application to crash

It seems that using MBProgressHUD is causing my application to crash. Without the HUD code, the following runs just fine, but with it, it crashes: { ... HUD = [[MBProgressHUD alloc] initWithView:self.view]; // Add HUD to screen [self.view addSubview:HUD]; // Register for HUD callbacks so we can remove it from the...