cocoa-touch

Alternative for sizeWithFont: method

Hi! I have a class which work is to parse a text into several pages. I use sizeWithFont: method to identify when one page ends and another starts. But unfortunately since the amount of text which needs to be parsed is pretty big, whole operation needs to be performed on a background thread (takes several second to complete). And therefo...

Why do you use an underscore for an instance variable, but not its corresponding property?

I am new to iphone development.I am doing research on voice recording in iphone .I have downloaded the "speak here" sample program from Apple.It consist of LevelMeter.h file, in which @interface LevelMeter : UIView { CGFloat _level, _peakLevel; } The property are set as @property CGFlo...

IPhone FIlewrappers and document packages?

Suppose I have an model object class Box. In my Box class I add images references (png), audio (mp3) etc... Rather than store them as NSData it seems better to reference the paths to the files...to save memory. I would like archive this Box class. On the desktop we would use Document Packages (NSFilewrapper). But this class is not part ...

How can I implement a "double" UITextField?

I am trying to generate a UITextField in a view like this. I don't mind using IB or doing it programmatically. ...

What is the proper way to access local variables in a delegate?

I'm trying to access an NSMutableArray which is a data member of my AppDelegate class. It is synthesized in the implementation, and is an array of a custom class which has a "name" NSString data member. I currently use it to fill a Table View (a SubView) like this: cell.textLabel.text = [[[delegate contentArray] objectAtIndex:indexPat...

NSManagedObjects that I own being released by main.m?

First, in my root view controllers viewDidLoad, I initialize an NSDictionary with arrays of NSManagedObjects, like so: - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Decks"; UIBarButtonItem *browseButton = [[UIBarButtonItem alloc] initWithTitle:@"Browse" style:UIBarButtonItemStylePlain target:self action:@selecto...

How do I delete all objects from my persistent store in Core Data?

Hi all, I have Core Data working in my app. So, I fetch an XML file, parse the data into model objects and insert them into core data. They are saved in the persistent store and I can access them when I relaunch the app. However, I want to be able to refresh the data in the persistent store at will, so I need to first remove existing ...

Laying Out UIView Subviews with Size Constraints

Given a view hierarchy that looks something like this: ContainerView UIScrollView ModuleView ModuleView ModuleView ... I'd like the ContainerView to lay the ModuleViews out in some arbitrary fashion (list, grid etc.). To do this, I'd implement -[ContainerView layoutSubviews] which would iterate through the ModuleView...

Memory warning and crash: how to handle it

I use instruments to see memory leaks. At least in one scenario where I am constantly flicking through slides/pages (inside UIScrollView) I don't see any memory leak. Using instruments - under "Allocation lifespan" I switch to view "Created & Still Living" and see memory around 1.17MB throughout. I assume this means my app is using only...

UITableView section header in editing mode only

The table view section headers in my plain (non-grouped) UITableView only appear when the table has been placed into editing mode. This is because I have two sections in the table view: Active and Inactive. I only wish the Active section to be displayed normally, but require both Active and Inactive to be displayed when in editing mode. ...

Unable to save correct Date using CoreData

I created a CoreData application using the Cocoa Touch Template. I modified the included .xcdatamodel file to have an attribute called 'Date' with datatype of 'Date' and other string attributes. I use following codes to save data for the 'Date' field: NSDateFormatter *dateFormatter=[[[NSDateFormatter alloc] init] autorelease] ; [dateFo...

Is it possible to write i file to the computers file system from the iPhone device?

I need to save an camera image from my application to the desktop so i can preview it. is it possible? The images that comes with the simulator seems to be too small. ...

Get NSString/NSData object from hardcoded bytes saved as NSString object in webservice response

Hey all, I am working with the iPhone SDK and I have to process a webservice response I receive from an external service. The response data consists of an XML string that was UTF8-encoded to a byte array. This byte array is converted to string This string is put into a XML wrapper element The wrapper is returned via an HTTP response ...

Iphone App Crashes - But sometime works(50%-50%)

Hi All I am using following code for showing a next view(tableview) in Iphone app. It sometime works and some time app crashes without any exception log NSLog(@"Ok"); is log everytime 50% attempts application crashes -(IBAction)statusInitiationButAction:(id)sender{ @try { NSArray *tempArrIniId = [eventInitiationArray v...

Zoom UIScrollView with multiple images

I have a UIScrollFrame that contains multiple UIImageViews. What is the correct way of supporting zoom in such a control? Which view should 'viewForZoomingInScrollView' return? ...

get the UIImage (or CGImage) from drawRect

I'm calling the following code from drawRect - (void) drawPartial:(UIImage *)img colour:(UIColor *)colour { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextTranslateCTM(context, 0.0, self.bounds.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextDrawImage(c...

Core Data best practices question for Navigation iPhone App

Using Apple's Mail application as an example; pretend it uses Core Data. When you touch an email account, it shows you all the messages in that account. So the controller did a fetch request for all the messages in that account. Then you touch a message and drill one level deeper, now you are viewing a single message. This single messag...

UIScrollView within UIScrollView

I have got a hierarchy where UIScrollviews exist within each other. How may I redirect swipe events for a certain area to an inner scrollview? ...

iPhone SDK - Get image from camera/camera roll, process w/ OpenGLES

I am writing a basic image processing app. Right now I have code in place to load an image via the Camera or the image picker and set it as the source image for a UIImageView object in my interface. The object is configured with the "Aspect Fill" property, so I don't have to programmatically crop the image. Looking at the sample code pr...

Fade In and Out Audio in iPhone SDK

Hi Everyone: I am wondering if there is some way to fade in and out audio using AVAudioPlayer in CocoaTouch, with a pause command once the music finishes fading and then a play command once the fading begins. I have heard that one can use NSTimer for this purpose, but I am unsure of the easiest way to accomplish this. Thanks for any h...