cocoa-touch

Cocoa Touch: Creating and Adding Custom View

I create a custom view in cocoa touch that is superclassed by UIView and in my main controller I initialize it and then add it as a subview to the main view, but when I add it to the main view it calls my initializer method again and causes an infinite loop. Am I going about creating my custom view wrong? Here is the mainView - (void)lo...

className method?

I have just been watching the Stanford iPhone lecture online from Jan 2010 and I noticed that the guy from Apple keeps referring to getting an objects class name using "className" e.g. NSArray *myArray = [NSArray arrayWithObjects:@"ONE", @"TWO", nil]; NSLog(@"I am an %@ and have %d items", [myArray className], [myArray count]); Howeve...

Differences in accessing resources between Simulator and Device?

Is there some difference between the way that bundle resources can be accessed on the iPhone simulator versus a device (in my case, an iPad)? I am able to access a file on the former, but not the latter. NSString *filePath = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] bundlePath], @"/AppResources/html/pages/quickHelp.html...

NSFetchedResultsController not processing certain section driven moves

I utilize a NSFetchedResultsController (frc) with a Core Data store. I implement all the frc delegate methods. The table is sporadically updated by background threads. All the inserts, deletes and updates work fine, with the exception that updates to the frc's index key for rows toward to the bottom of the table (50 rows), do not result ...

Memory Leak when using SDURLCache (subclass of NSURLCache)

I am using Olivier Poitrey's SDURLCache (github link) as an alternative to NSURLCache to enable disk-caching in an iPhone app. It works very well but is curiously leaking a NSHTTPURLResponseInternal when a disk cached object is returned (no leak when object is returned from memory or no object found). The following code snippet shows ho...

imagePickerController didFinishPickingImage not being called.

Hello, I am trying to save an image I take from a UIImagePickerController but I am not, well, being able to. This is the code I am trying to use to save the image: - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { UIImageWriteToSavedPhotosAl...

Custom UITableViewCell Best Practice?

I am always subclassing UITableViewCell's and drawing them in code. Is there a good tool to visually get rect sizes so I don't have to guess and check all the time? ...

Drawing UITableViewCell in IB

Is it bad practice/not efficient to draw UITableViewCell in IB vs drawing in code? ...

Custom UITableViewCell not appearing when row height is set

I have a custom UITableViewCell which I have created in IB. My labels display when I don't over-ride: - (CGFloat)tableView:(UITableView *)tblView heightForRowAtIndexPath:(NSIndexPath *)indexPath however my content is squished. I want the height to be 120px so I have the following: - (CGFloat)tableView:(UITableView *)tblView heightFor...

iPhone noob - different method types?

My apologies in advance for what is probably a really dumb question. I'm familiar (or at least getting familiar) with instance and class methods in objective-c, but have also seen method implementations that look like this: #import "Utilities.h" #import "CHAPPAppDelegate.h" #import "AppState.h" @implementation Utilities CHAPPAppDeleg...

Confused about copying Arrays in Objective-C

Lets say I have an array X that contains [A,B,C,D,nil]; and I have a second array Y that contains [E,F,G,H,I,J,nil]; If I execute the following: //Append y to x [x addObjectsFromArray:y]; //Empty y and copy x [y removeAllObjects]; y = [x mutableCopy]; What is the value of y? is it?: [A,B,C,D,E,F,G,H,I,J,nil] Am I performing the ...

Figure out UIBarButtonItem frame in window?

Hey guys, UIBarButtonItem does not extend UIView, so there is nothing like a frame property. But is there any way I can get what is it's CGRect frame, relative to the application UIWindow? ...

Set a grouped UITableView to start at a given section?

I have a grouped UITableView that has basic data inside it, but I would like to start the UITableView at a certain section when the app loads, can this be achieved? Thanks Mark ...

view shifts up after adding right barbuttonitem to navigation controller iphone sdk

Hi all, In my application, the view below navigation controller moves up and is visible below the navigation bar as it's becoming transperant after adding a barbuttonitem programmatically to the navigation controller which I'm adding to view through an xib. This' the way I'm adding it: UIBarButtonItem *comment = [[UIBarButtonItem allo...

App development: Always subclass, always load from NIBs - caveats?

This is Cocoa Touch (et al), iPhone, XCode only. After completing my first commercial iPhone app, I'm struggling a bit to find a way to start and expand an app from scratch which gives the most linear development (i.e., the least scrapping, re-write or re-organization of code, classes and resources) as app specs change and I learn more...

Best approach to decompressing individual files by relative path inside zip archive

We're looking for a solution to keep thousands of html/image assets inside a .zip archive, and decompressing single files on-demand as a local web server needs access? More than a couple hundred files or so on the iPhone OS file system absolute kills the backup process, and is probably not advisable for the flash disk either. Solutions ...

How do I copy or move an NSManagedObject from one context to another?

I have what I assume is a fairly standard setup, with one scratchpad MOC which is never saved (containing a bunch of objects downloaded from the web) and another permanent MOC which persists objects. When the user selects an object from scratchMOC to add to her library, I want to either 1) remove the object from scratchMOC and insert int...

UITableViewCell not appearing/reusing correctly from NIB

I have created a custom UITableViewCell from a NIB. Everything appears when the rowHeight is not set (albeit, everything is squished). I am not sure if I am reusing and creating the cells properly: // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath ...

Do I need to set heightForRowAtIndexPath if I am using a custom UITableViewCell?

Do I need to set heightForRowAtIndexPath if I am using a custom UITableViewCell? In my NIB I have already set the cell height. When I over-ride heightForRowAtIndexPath the contents of my cell don't appear, even though it is set to the height defined in the NIB. If I don't over-ride heightForRowAtIndexPath the contents of the cell appea...

Programatically created ViewController and awakeFromNiB?

I am creating a viewController programatically (hopefully the right way) My problem is that I previously created the controller in IB and have code I want to call in awakeFromNib. As I currently have things viewDidLoad works fine but awakeFromNib does not. Is there anyway to get awakeFromNib to call or an alternative method that I can us...