objective-c

iOS Memory Management: ivars, static, and NSStrings

Hi there, I have managed to get myself confused about some elements of memory management. I am new to objective-c, and memory managed languages generally. I have read the memory management guidelines, but I remain confused about a couple of things. 1) Is there any need to clean up ivars, and method variables that are not retained b...

How can I print "\n" using NSLog?

How can I print "\n" to the console by using NSLog or printf function? Basically I was trying to print a String with value "Hello\nWorld". My requirement is, I want to print it AS IT IS. But when I tried to print, it was printing like, Hello World not as Hello\nWorld ...

iPhone UISearchBar view not updating immediately?

I currently have a UISearchBar and UIDisplayController defined in my RootViewController as: - (void)viewDidLoad { [super viewDidLoad]; //Add the search bar aSearchBar = [[UISearchBar alloc] initWithFrame:CGRectZero]; [aSearchBar sizeToFit]; aSearchBar.delegate = self; aSearchBar.placeholder = @"Search YouTube......

NSString to NSDate with float values

Hello, I'm developing an OS X desktop application which will track time for a car racing event. The difference between pilots can be very small, so the collected data for each lap has a floating point value for the seconds: bestLap = @"00:01:39.5930000" But I need to compare each pilot's time and sort it. I'm trying to convert it to...

Does UITableView's indexPathsForVisibleRows return the wrong paths?

Hi there, I use the following code to trigger image downloads in visible cells/paths: - (void)loadImagesForOnScreenrows { NSArray *visiblePaths = [tableView indexPathsForVisibleRows]; for (NSIndexPath *indexPath in visiblePaths) { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if([cell viewWithT...

How do I persist data managed by NSArrayController without Core Data or NSKeyedArchiver?

I hope you'll excuse the seemingly broad nature of this question, but it gets quite specific. I'm building a document-based Cocoa application that works like most others except that I am using SQLCipher for my data store (a variant of SQLite), because you don't get to set your own persistent data store in Core Data, and also I really ne...

Objective-C arrays and class variables

I am porting an Android app I made to iPhone and running into problems with the syntax (I think) I'm basing the project off of the example from http://iphonedevelopment.blogspot.com/2009/04/opengl-es-from-ground-up-part-2-look-at.html I would like to pull out the geometry from the rendering process to keep the code modular but I can'...

iphone app checking internet access

Possible Duplicate: How to Check for an active Internet Connection on iPhone SDK? How can I make my app check for internet access. If it's not available it should present a dialog box telling the user and show the select a network view. ...

Objective C (iphone/ipad) - carousel coding best practice

I need to build a scroll view (with 10 items for example) that can be continuously scrolled (with paging enabled). In other words as you keep scrolling to the right, you see the item you started with once to get to the end, and it just keeps looping. I'm looking for recommendations on how to a approach this. I will be receiving an array...

how do you register a protocol for your iphone app?

So that clicking an url like this app://file1.html on the iphone will open your app? ...

Why is my UIView unresponsive after a reload?

I have a viewController that pops a modal view with a UIWebView. If I visit a particularly heavy page, I start getting memory warnings, followed by the parent view getting unloaded. This is all fine and dandy, but when I close the modal view, my parent reloads (as expected) but is not longer able to process any touch events. The app re...

Always getting the same height using sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode:

The CGSize returned by sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode: contains always the same height. Why is that, and is there a way around this? I want to align a string vertically and it may not be truncated, unless it can't fit on a single line using the minimum font size. So I try to use this method to get the lin...

Loading UIImagePickerController view at runtime

I am currently writing a program where if a certain condition is true, it should load a modal UIImagePicker camera view. I declared the UIImagePickerDelegate in the ViewController for the application. However when the program is instructed to load the modal camera view the camera view will appear but the screen is just black and the canc...

iPhone apps: Linking to review page

I've seen several many apps link to the "write a review" page on the app store. What URL are they using? I know it's a Phobos URL. Thanks. ...

How to scale up and crop a UIImage?

Here's the code I have but it's crashing ... any ideas? UIImage *tempImage = [[UIImage alloc] initWithData:imageData]; CGImageRef imgRef = [tempImage CGImage]; [tempImage release]; CGFloat width = CGImageGetWidth(imgRef); CGFloat height = CGImageGetHeight(imgRef); CGRect bounds = CGRectMake(0, 0, width, height); CGSize size = bou...

Performance test: sem_t v.s. dispatch_semaphore_t and pthread_once_t v.s. dispatch_once_t

I wanted to know what would be better/faster to use POSIX calls like pthread_once() and sem_wait() or the dispatch_* functions so I created a little test and am surprised at the results (questions and results are at the end). In the test code I am using mach_absolute_time() to time the calls. I really dont care that this is not exactl...

UILabel with some effects

Hi, Can anyone help me how could I achieve an effect like this image sample image on a UILabel. As you can see there some like a stroke/bevel effect on the label. I got this image from a clock app so it means that its not a static image. Thanks in advance.. ...

How do I show a modalviewcontroller well in a tableview

I need to show a modal view controller when users click a info button on the top right of my application. ...

Percentage Calculation always returns 0

I am trying to calculate the percentage of something. It's simple maths. Here is the code. float percentComplete = 0; if (todaysCollection>0) { percentComplete = ((float)todaysCollection/(float)totalCollectionAvailable)*100; } Here the value of todaysCollection is 1751 and totalCollectionAvailable is 4000. Both are int. But percen...

How to stop text in a UITableViewCell running into the area used by the disclosure indicator?

I am display some long text in a cell, and resizing the height of the cell using heightForRowAtIndexPath. However, when the text is displayed it is running into the area used by the (blank) disclosure indicator. When such a row is selected, and the checkmark is displayed, the text reformats itself to not use the indicator area, causing...