objective-c

Controlling AutoCorrect View Position on iPhone

Is there a way to control the position of the auto correct view that pops up while typing in a UITextField? By default it appears to always appear below the text field. However in Apple's apps like SMS it sometimes appears above the text field. For text fields aligned right above the keyboard the auto correct is blocked by the keyboar...

How do you make a button remove a row with Core Data in an Outline View?

I have an outline view with 2 entities being displayed inside it so It is connected to a NSTreeController. I have created a button and binded it to the NSTreeController's Controller Key 'canRemove' under Availability>Enabled. But when you run the App the button is always Disabled even when a row is selected in the Outline View. How can t...

Efficiency of create views programmatically vs IB

I have a large number of UIViews that are created in the app delegate applicationDidFinishLaunching and added to an NSMutableArray. The user pages through these views using a page control and scroll view. I created the UIView and its child components in IB. They are wired to a controller. To create 170 views on the iPhone takes about...

Declaring, Properties, Synthesizing, and Implementing int[] array in Objective C

How do you declare, set properties, synthesize, and implement an int array of size 5 in Objective C? I'm writing this code for an iphone app. Thanks. ...

How can I dynamically create an instance of an class?

Example: I have 10 view controllers, which are all allocated and initialized in the same way: UIViewController *controller = [[MyViewController alloc] initWithNib]; (note that -initWithNib is a custom method of a UIViewController subclass) The next view controller class is OtherViewController, and so on. I want to load the view cont...

Class Design for delegate, outlets, and mouse events

Here's a simplification: I have an application with several buttons. If it is the first time the application is launching, I want to do some special things. In my AppController class, which is a delegate of NSApp, I use the delegate method -applicationDidFinishLaunching: to perform the test. After I've detected that it is the first t...

NSMutableArray addObject crashes iPhone app

I have a class XMLParser. It works fine as long as I don't remove the commenting of the line that adds the nodes to the NSMutableArray: [nodes addObject:self.currentNode]; If I do that, the application crashes - without leaving any trace in the debug log. How can this be? XMLParser.m: #import "XMLParser.h" #import "MyViewController....

How can I listen for didRegisterForRemoteNotificationsWithDeviceToken outside the app delegate

I would like to my object to receive notification with the DeviceToken becomes available. Is there a way to delegate only certain functions from the UIApplication to my class? Update: I'm not so much interested in accessing it from the application delegate, I already have an application delegate, but want to respond to the event via c...

iPhone SDK: NSString-to-C-char-array crashes on second invoke to drawRect

I could not find a post exactly like this, so please forgive me if this is a duplicate. I am trying to write text using a Core Graphics context. I can do it the first time, no problem, but the second time crashes my iPhone app. Here is a code snippet: NSString *name = [MyClass getName]; const char *cname = [name UTF8String]; [self dr...

iPhone SDK: How do you measure the width and height of a string using Quartz?

Before I ask my questions, this is from Apple's documentation re: how to determine the width of a string using Quartz: If text measurements are important to your application, it is possible to calculate them using Quartz 2D functions. However, you might first consider using ATSUI, whose strength is in text layout and measurement. ATSU...

Logging all cocoa events?

I'm doing usability testing and would like to log all user input events: mouse movements, clicks, drags, and keyboard input. I'm not having much luck figuring out how, or finding any code to do so. Any hints? I took a look at the CoreGraphics EventTap mechanisms, but I'm worried that it will be too low-level; I'd like to actually know wh...

Is there a resource to explain how to export photos to a web site, for example like iPhoto to Facebook Export?

I am trying to understand the process of exporting from iPhoto to a web site. This would website would be a content management system. I have already located the iPhoto SDK for Exporting but cannot get my head around how to change the destination to a web site/service and the process involved. I am looking for some resource to give me...

Finding the closest point to a given point

Hello- I have searched all over for this, but I can't seem to find the best approach to this. I have about 22000 lat/lon points and I want to find the closest one's to the current location of the iPhone. I've seen people ask about Quad Trees, Dijkstra's Algorithm, and spatial databases. Which is the best for the iPhone? Spatial databases...

In Quartz 2D, Is it possible to mask an image by removing everything but the color channel you want?

So I tried to use the Quartz CGImageCreateWithMaskingColors function, but he only problem is that it masks the color range you are selecting. I want to mask everything but the color range I am selecting. For instance, I want to show all red colors in a picture but remove the other channels (Green and Blue). I am doing this in Objecti...

Exit NSThread

how to exit thread while its in running mode...when i use NSThread exit my app get hanged... Can any one help me ? what could i use here to exit thread or close thread Thanks Its my first post here. ...

Is there a way to trap messages sent to nil in Objective-C?

I've just been bitten by an annoying bug that was made obscure by the "send message to nil is ok" behaviour in Objective-C. I've seen http://stackoverflow.com/questions/156395/sending-a-message-to-nil, and the consensus seems to be 'thats how we roll' in Objective-C. Now, maybe I don't have enough experience in Objective-C, but it seem...

Why am I getting these Errors in the Console when Debugging in XCode?

I am creating an App and when I run it I check the Debug Pane, I am getting these errors Inside the Console: 2009-05-27 07:18:03.852 Spark[1228:10b] [ valueForUndefinedKey:]: the entity Projects is not key value coding-compliant for the key notes. 2009-05-27 07:18:09.029 Spark[1228:10b] Error setting value for key path selectionIndexPa...

10.5 base SDK, 10.4 deployment: how to implement missing methods

I have a project that targets both Mac OS X 10.4 and 10.5, where 10.5 is the base SDK. Some methods like -[NSString stringByReplacingOccurrencesOfString:withString] are unavailable in 10.4. I could just implement the functionality by hand. Another option would be to implement the method as a category, but that would mess with the 10.5 i...

How to delete a row in UITableView manually?

Here's what I've come up with: NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:1]; // my table view has 2 sections [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop]; Everytime I build and run, it throws the following exception: Invalid update: inval...

How can i connect MySQL database with objective project?

I want to connect MySQl database with my iphone application.Read, write, save some data into the database.How can i do this. ...