cocoa-touch

Setting each cell in its own group

My UITableViewCells take up the full viewing area. I'd like to use a grouped table so the cells appear to have rounded corners. Right now, if I set the number of sections to something greater than one, I get the number of sections in grouped style but all the cells repeat in each section. How do I setup the table so each cell is in a ...

NSKeyedArchiver works in iPhone simulator, fails on device

Hi there, I've got a simple app that's trying to save some data between invocations using NSKeyedArchiver/NSKeyedUnarchiver. It works fine on the simulator, but when I export it to real iPhone hardware, NSKeyedArchiver fails to be able to write to disk. I'm using the class method [NSKeyedArchiver archiveRootObject:myRootObject toFi...

Position of UITableViewCell

I'm using a tableview to display a list of rows and when selected, I want additional controls to appear right below the cell, probably in another view which I will control. So far, I've managed to get a reference to the selected cell by running through the visiblecells array in the tableview but the frame property always returns a y-coo...

UIView inside another UIView doesn't call methods

Hi there, I have the following problem: A UIView with a UIViewController, but I have another view, something like an customized keyboard, and this "keyboard" have another UIViewController associated. I'm adding this keyboard to the original UIView like that CustomizedKeyboard *customized = [[CustomizedKeyboard alloc] initWithNibName:@...

Leaking Memory on iPhone :(

Hi Everyone. I'm a beginner at C, Obj-C and the iPhone, and I'm trying getting to grips with a lot of terminology used. I hope one of ye can help with a problem I have been struggling with for a few days now. My code below is a method which call up a nib containing a search field and a table. The table is populated from a search of the...

How to display multi-line text without scroll in UIView?

I have multi-line non-HTML text (with newlines). Need to output it inside ScrollView or just UIView. I can't output it as UITextView: can't find how to resize UITextView to the size of text and/or disable scroll in it. Should I output text to Label? Or there's something more proper for that? Thanks. ...

Sorting an NSMutableArray with custom objects 'overwrites' some objects

For a little iPhone application I am making, I want to sort a NSMutableArray. I found 2 ways of doing this, but they both result in the same thing. Sorting the array will cause some objects to 'overwrite' eachother. First off, here is my code: AppDelegate.h NSMutableArray* highScores; Somewhere down that AppDelegate.h, I also make ...

How to word wrap text?

In Cocoa, there is a method (lineBreakBeforeIndex:withinRange:) on NSAttributedString to find appropriate line breaks in a piece of text. Since NSAttributedString does not exist on the iPhone, does anyone have any suggestions for similar functionality? Edit: Realized that I'm really looking for a word-wrap algorithm. For example, I wan...

Navigating back & forward in a UINavigationController causes crash

I'm getting a consistent crash when I create a simple app that uses a navigation controller. Basically choosing an item in the first table successfully creates & pushes the sub viewcontroller, and the back button works just fine. But when I try to choose the item again I get a strange crash in GDB. I get no errors, simply the debugger...

UIDatePicker and NSDate

I have an app where I ask for the users birthday with a UIDatePicker then store it in standard user defaults. When the app is opened again I get the date again and then want to set the UIDatePicker to that date but it's crashing and not accepting the date. It's being stored in the format "June 8, 2009." How do I need to do this? This is...

Rearranging buttons in an iPhone alert?

Is it possible to have alert view buttons above each other instead of next to each other? ...

Text link in Alert View message

Is it possible to add a text URL Link in an Alert View message? ...

What is the right way to check for a null string in Objective-C?

I was using this in my iPhone app if (title == nil) { // do something } but it throws some exception, and the console shows that the title is "(null)". So I'm using this now: if (title == nil || [title isKindOfClass:[NSNull class]]) { //do something } What is the difference, and what is the best way to determine whether a ...

NSLog tips and tricks

Hi, I'm doing a presentation on debugging in Xcode and would like to get more information on using NSLog efficiently. I'd like to know if there are any tips and tricks to using NSLog which you guys have picked up. For example, is there a way to easily NSLog the current method's name / line number? is there a way to "disable" all NSLo...

Change UIDatePicker from 12 hour clock to 24 hour clock and back

Hello, I'm sorry to make my first question here a bit of a simple one -- I've spent a day reading the NSLocale and NSCalendar class descriptions but I couldn't see if this was possible. I have a UIDatePicker in the UIDatePickerModeDateAndTime mode. It is currently displaying date and time according to the user's locale, which is the d...

UITableView disable swipe to delete, but still have delete in Edit mode?

I want something similar as the Alarm app, where you can't swipe delete the row, but you can still delete the row in Edit mode. When commented out tableView:commitEditingStyle:forRowAtIndexPath:, I disabled the swipe to delete and still had Delete button in Edit mode, but what happens when I press the Delete button. What gets called? ...

iphone app - adding another view.

Hi, I am working on a iphone app but found that I have now require another view / window to get the user to input and save data / information there. how do I add another view? do I add it in interface builder and then link it in the main app delegate or will it have its own .h and .m files. I selected a window view app to start with,...

Writing to a property list on the iPod Touch not working but works in simulator

In the application that I am writing I am trying to write a list of fortunes for a fortune cookie out to a property list. In the simulator this works as expected and everything is great. On the iPod Touch I have it reads from said list fine but it never updates the list. Are there any differences between updating property lists using th...

How to compare UIColors?

I'd like to check the color set for a background on a UIImageView. I've tried: if(myimage.backgroundColor == [UIColor greenColor]){ ...} else{ ...} but that doesn't work, even when I know the color is green, it always falls into the else part. Also, is there a way to output the current color in the debug console. p [myimage backgro...

Toolbar placement off with Interface Builder

I have a view xib that I'm manipulating through IB (for various reasons) and it will be launched as a modal view in code. I have a Toolbar at top and another one at bottom with some other UI elements in between. When I run the app, the placement of the top Toolbar isn't as I see it during the layout in IB. In IB, the top Toolbar is pla...