objective-c

NSRequest vs initWithURL

Should I use initWithURL or NSRequest to download an XML file when using NSXMLParser? I'm downloading a feed and I'd like to get progress information for my download. ...

Display bytes in NSLog

Hi there How can I display these bytes in NSLog? const void *devTokenBytes = [devToken bytes]; Cheers Cyril ...

How can I add a UISearchDisplayController to a UIView?

How can I add a UISearchDisplayController to a UIView? Interface builder won't let me. ...

PDF Viewer in IPad

Hi, I am creating one app in which I need to view pdf, word, and excel files. Can I view these files without using web view? Can anyone provide me with sample code for doing the same. Thanks alisha ...

iAd appears in simulator but not on device

When I run my application I can see my iAd in the simulator, that is pre-filled with "Test Advertisement" However, when I run the application on my device, the iAd area is blank, with no pre-filled ad. Why is this? My iAd is in a UITableViewCell: #import "iAdCell.h" @implementation iAdCell @synthesize adView; - (id)initWithStyle:(...

Is there a reverse "setValuesForKeysWithDictionary" - a makeDictionaryWithObjectProperties?

Hi I parse some JSON from a web service, this gives me an NSDictionary, I use this dictionary to populated properties on a valueEntity of type NSObject by [myObject setValuesForKeysWithDictionary:JSONDict]; (myObject has the same property names and types as the dictionary from the JSON parser) name = name count = count startDate = ...

Wired NSDictionary problem...

Hello, i have the following code : NSDictionary *dict =[[NSDictionary alloc]initWithObjectsAndKeys:myarray1,@"array1",myarray2,@"array2",nil]; NSArray *shorts=[[dict allKeys]sortedArrayUsingSelector:@selector(compare:)]; for(NSString *dir in shorts){ NSArray *tempArr=[dict objectForKey:dir]; for(NSString ...

UITableView and the alertView: clickedButtonAtIndex method

I am playing around with xCode and was trying to create a small app that comprises of a table view (built using an array) comprising the names of various individuals. The user would be able to click on one of the rows in the table view and would be shown a UIAlert with an option to call the person or cancel. If they click on cancel, the...

Calculating line breaks every N characters?

I'm making an RSS parser for iPhone and iPod Touch and I need to be able to set the number of lines shown in each cell for each article. I'd like to break every 39 characters, which is the most that fits on a line at the font size that I'm using. I'd like to take the number of characters in a string and divide it by the number of charac...

Convert NSDate to NSString with NSDateFormatter with TimeZone without GMT Time Modifier

I'm initializing my NSDateFormatter thusly: NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]]; [dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss z"]; [dateFormatter setTimeZone:[NSTimeZone timeZoneForSeco...

Lazy Loading in Objective-C - which is more correct?

This is a small detail but everytime I lazy load something I get caught up on it. Are both of these methods acceptable? Is either better? Assume that the variable has the retain property. Method #1 (AnObject *)theObject{ if (theObject == nil){ theObject = [[AnObject createAnAutoreleasedObject] retain]; } return theO...

Had a problem with the special charactered url when opening with in the application

Hi all, I am trying to open an url with in the application. It has some special characters like, ./_ =| | #. It is not opened when I try to open it with in the application like [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneUrl]]; but it is not responding. When I Pasted the url in safari of simulator it is working ...

Memory Management example

Here is some of the code from one of my classes, I was wondering am I handling the memory right or am I leaking anywhere? @implementation CardViewController @synthesize playerImage; @synthesize cardLabel; @synthesize card; @synthesize frontView; @synthesize backView; @synthesize nameLabel; @synthesize infoLabel; @synthesize delegate; -...

How to hide one of the two Right buttons in the navigation bar

Dear all I have implemented two buttons in the navigation bar on the right side on top of a text view as; UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 112, 44.5)]; // toolbar style is the default style // create an array for the buttons NSMutableArray* buttons = [[NSMutableArray alloc] ...

OTX - Method offset in binary

So I'm dealing with a fat binary, and I'm trying to find the method offset for frame [FOOClass abcdMethod]. Using otool I get the __text segment addr and offset. The only problem is that offset in decimal given in the output equals the starting address of the __text segment. My question is. How can someone deduct the offset of the me...

UIPickerView - store contents in file

I have a UIPickerView which I want to initialise with a large amount of data. The easiest way to maintain this data is in a spreadsheet, and so I have saved it as a CSV. Unfortunately, I am having a lot of difficulty reading this file. (I have read a lot of documents on how to do it, but it just won't read the file. It say's its null.) W...

applicationWillEnterForeground vs. applicationDidBecomeActive, applicationWillResignActive vs. applicationDidEnterBackground

Which is the proper delegate to implement when an application is waking up from being in the background and you want it to prep it to be active? applicationWillEnterForeground vs applicationDidBecomeActive -- What's the difference? Which is the proper delegate to implement for when an application is going to sleep and you want to prep ...

iAd: ADBannerViewDelegate methods only called once after viewDidLoad()

I have the following ADBannerViewDelegate implementations: #pragma mark ADBannerViewDelegate Methods - (void)bannerViewDidLoadAd:(ADBannerView *)banner { self.headerView.frame = CGRectMake(0, 0, 320, 94); [self.tableView setTableHeaderView:headerView]; adBannerView.hidden = FALSE; } - (void)bannerView:(ADBannerView *)banner...

App Crashes because iAd Fails to Resume in Time

My app runs fine when I don't have iAds. As soon as I display an iAd the system shuts down my app because the iAd can't resume in time. How do I resolve this? Elapsed total CPU time (seconds): 1.380 (user 0.880, system 0.500), 14% CPU Elapsed application CPU time (seconds): 0.000, 0% CPU Thread 0: 0 libSystem.B.dylib ...

drawRect function hindering performance

I am working on drawing a snake which moves using a CADisplayLink using DrawRect. The problem is when the snake is small the speed is fine, but when the snake grows in length the snake becomes really slow. I keep track of the snake using the followig variables: - variable to keep track of snakes head - variable to keep track of snakes ...