cocoa-touch

NSUserDefaults: What's the +resetStandardUserDefaults method good for? How can I provide "system settings"?

I want the user to be able to make some preferences like colors, prefered images, etc. When I use NSUserDefaults for this, on first start of the app there will be no preferences, right? So, every time I want to get a preference like NSInteger avatarID = (NSInteger)[[NSUserDefaults standardUserDefaults] objectForKey:@"avatar"]; I have t...

Pre-setting uislider values

Is there a way to preset UISlider values to something such as: 100, 121, 10000, 40505, 100000, 460322, 1000024, 5005230, etc... The numbers don't have a pattern. As the user moves the slider, I'd like to display the above numbers as corresponding to where the user is on the slider. The slider displays numbers in specific increments a...

How can I reset the NSUserDefaults data in the iPhone simulator?

I've added NSUserDefault data retrieval to my app, which is pretty nice. But for testing I would like to reset all the data I added to the defaults database, so that everything is in the state when the user launches the app the first time. I tried to call: [NSUserDefaults resetStandardUserDefaults]; but that doesn't do anything. The d...

How can I detect if the user just wanted to scroll, and not tap on an UIImageView inside a UIScrollView?

I've implemented an UIScrollView which contains a grid of UIImageView objects. For both, the superview and it's subviews, userInteractionEnabled is YES. As the user scrolls and his/her finger touches an UIImageView, it imediately recognizes a tap on that, which is not what I want ;) Inside of that UIImageView objects I have this method:...

How can I make a view that's managed with an Tab Bar fade smoothly in/out rather than flashing hardly in/out?

I have an Tab Bar controller and a nice tab bar on the bottom of my app. There are three buttons. When I tap one, then the view controller from that tab bar is "invoked" and the new view appears immediately. That's like banging a door very hard, so that everyone in the neighbourhood can hear it. I would like to have a softer transition, ...

How can I add CGPoint objects to an NSArray the easy way?

I have about 50 CGPoint objects that describe something like a "path", and I want to add them to an NSArray. It's going to be a method that will just return the corresponding CGPoint for an given index. I don't want to create 50 variables like p1 = ...; p2 = ..., and so on. Is there an easy way that would let me to define those points "i...

Is there a way to put a scalar type like CGPoint (or any self created) into a NSArray?

Probably I could create a class that holds an CGPoint as instance variable, like a wrapper. Does that make sense? I feel uncomfortable with that, though. I hope there is an better solution. How about any self-created scalar type? Like MyCoolScalarType? ...

How can I programmatically determine if an "touchUpInside" event occured?

It seems like if this method will be called any time the user touches my view: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; if ([touch view] == self && [touch tapCount] >= 1) { // do something... } } I've implemented this in an UIScrollView. The documentation...

UITableViewCell: How to prevent blue selection background w/o borking isSelected property?

I have a custom UITableViewCell subclass. I have set the contentView of my cell subclass to a custom UIView class in which i am overriding -drawRect: and doing all of the drawing there. Also, I am setting cell.contentView.opaque = NO in order to achieve transparency in certain areas of the cell (unfortunately, a backgroud image behind...

How can I programmatically determine CPU usage rate or how busy / occupied the system is in iPhone-OS?

My app is doing some pretty but heavy weight core animations during scrolling. Sometimes it crashes due to bad performance. So I need some way to find out if there is enough capability to make the animations, and if not, I just leave them away. Best way would be if I could ask the system how busy it is. UPDATE: I mean especially Core An...

How do i change the location of the text in UITableView?

How do i change the location of the text AND show the FULL string in UITableView? Here is a screen shot of what I have, once you look at it you will know what I mean. Thanks ...

Does anyone have a good way to scroll text off to one side, like a stock ticker in a label on a nib in an iphone app?

I want to scroll text starting on the right and make it smoothly move to the left and off the screen. Does anyone have an example of something they tried that worked? Thank You. ...

How to check for existing item in NSSet or NSCountedSet?

Hello, I'm currently populating model objects into an NSSet (perhaps I should be using NSCountedSet). The models should be unique. What I do is pull them in from a web service, and then instantiate them on the client-side and add them to a set. My problem is the following: There are times when I'll only pull one model and add it to the...

Why is UILabel 0x0?

I'm loading a nib as: ContentViewController *theController = [[ContentViewController alloc] initWithNibName:@"ContentView" bundle:nil]; which has a label on it. The view controller has an IBOutlet of UILabel with a @property of retain and synthesized variable. When I load the nib as above from another class and reference the label's...

An efficient way of redrawing a UITableViewCell once its data is available

Hi all, I currently have one UITableViewController that contains many cells with simple data in it. When the UITableViewController instantiates a UITableViewCell, it begins running a background thread for each individual cell to get its state from the server. The UITableViewCell is subclassed and already has a UIImageView property that ...

Can't include "self" in Objective-C description method?

I have a very straight forward class with mostly NSString type properties. In it, I wrote a trivial implementation of the description method. I found that whenever I try to include "self" in the description, it crashes my iPhone app. An example is something such as the following: - (NSString *)description { NSString *result; re...

Are there any tools or good techniques to find out where the performance bottlenecks are in an iPhone application?

I have an app that's half way done. The performance is not really good, and I wonder where the bottlenecks are. Although I can go ahead and start commenting out suspected lines of code, I wonder if there are any tools that would tell me which method cool took how long and what happened next. The stack trace isn't really that helpful. I ...

Core Data Primary Key

This may seem stupid, but I still couldn't figure out how to mark a attribute as a primary key in the xcdatamodel file. My persistent storage is sqlite file. Can anyone help me? In that case, how can I "validate" a ID to be unique? Should I write a validation method or something? ...

Are there easy functions for converting hours to seconds, seconds to hours, etc.?

I want to write some functions for that, but before I do: Are there any to convert between time units? ...

UITableViewCell's contentView's width with a given accessory type

On an iPhone, how do you figure out the width of a table view cell's content view when it is showing a certain accessory view (disclosure indicator, etc)? I need this in order to calculate the correct cell height for cells that contain wrapping, variable-length text. But when the table view delegate is asked for a cell height, it doesn...