objective-c

How do I add UIControls to a UIScrollView contentView?

I want to add UIControls to a UIScrollView, eg. UIControl *couponView = [[UIControl alloc] initWithFrame:CGRectMake(drawX,drawY,couponWidth,couponHeight)]; couponView.backgroundColor = [UIColor redColor]; [[scrollView contentView] addSubview:couponView]; //may not respond [scrollview.contentView addSubview:couponView]; //not a ...

expected specifier-qualifier-list before 'extern'

Hi guys, I'm trying to create a class with global constants: //Resources.h #import <Foundation/Foundation.h> @interface Resources : NSObject { extern NSString * const MY_CONST; } @end and //Resources.m #import "Resources.h" @implementation Resources NSString * const MY_CONST = @"my constant"; @end And getting this nasty error...

Change the number of rows in a section depending on a variable.

In my 'Sectioned' UITableView I have two sections, the first one for Attributes like name and the second one is editable where you can add objects. Here's a picture of it: There's an attribute that the user can change (in this case Type) which would to change the number of rows in second section. To be more specific, if one property i...

NSDictionary writeToFile

Is there a size limit to saving dictionaries? I am attempting to write a rather large dictionary with around 100 keys with nested dictionaries using writeToFile: but it never writes and is always false. Is this a limitation or am I doing something incorrect, The code i use is the following. NSArray *paths = NSSearchPathForDirectories...

Create a static library that can be weak linked

Is it was possible to add objects/classes to a static library in a way that would let them be excluded when the library is weak linked? I tried adding attributes to my obj c classes that tag them as "weak_import" but the compiler says it is undefined. ...

Try Catch Statement doesn't work on Simulator (but works on iPhone!!!)

Hi I have an Exception catching statement in my code, like the following: @try { for(NSDictionary* s in users) { do something .... } } @catch (NSException * exception) { NSLog(@"APIRequesetBase readUserInfo: Caught %@: %@", [exception name], [exception reason]); } @finally { } So this try stat...

How can I stop CALayers from animating?

Hi all, I've created a bunch of sublayers within my view, populating each one with a graphic, so effectively they are sprites. However, when I call [lineLayer setValue:[NSNumber numberWithFloat:0.5] forKeyPath:@"transform.scale"] it appears to 'tween' to that size instead of just appearing at the new scale. Is there any way of switchin...

Match several times in RegexKitLite

I'm trying to get some info out of a document. I'm trying to match the info I need with regex, which matches 3 numbers within a string. It works fine, but it only matches the first occurance. I need it to match an unlimited number of times because I don't know how many times this string will occur. NSString *regex = @"String containing ...

Drawing a 'turning wheel' using Core Graphics?

Can someone provide an example of drawing an iPhone-like turning wheel using Core Graphics. I know it can be done by drawing a sequence of lines but that requires a math formula to work out line points. Can someone help me with that? Here is how it should look like: It looks like it is made up of several lines with rounded edges and ...

Initalize A UISegment Control

I want to initialize my uisegement control to the second option. So when a button is clicked I want to set the uisegement control control to option 2. ...

MFMailComposeViewControllerDelegate setMessageBody problem

Hello guys! Here's my code: if (!_mail) { _mail = [[MFMailComposeViewController alloc] init]; _mail.mailComposeDelegate = self; CGRect mailRect = _mail.view.frame; mailRect.size.height = self.view.frame.size.height; mailRect.size.width = self.view.frame.size.width; _mail.view.frame = mailRect; _mail.vie...

Trying to free allocated memory borrowed when initializing an object, but getting Xcode warning

OK, so I have my main.m program code, and mvds suggested I free the allocated memory I borrowed from my class when I created a new instance. For some reason, when I attempt to free the memory using [converter free]; It gives me a warning saying that converter may not respond to -free, and once I finish my program, it spits out a bun...

Distributing apps compliant with iOS 3.0 +

I've been working on an app that I've successfully built for iTouch, iPhone 3G, iPhone 3GS, iPhone 4, running iOS 3.0+. It worked fine when I plugged it in to Xcode and built from there. However, after submission to the app store, it only builds on iOS 4.0. Are there any obvious reasons why? My build settings were: Active Architecture: a...

Initiating NSString outside an if() statement assigning it inside and releasing afterwards causes a crash

Sticking to the rule of releasing everything I'm creating, why does the line [cellText release] crash my app? It must be something really simple, I'm quite new to iPhone apps dev. ... NSMutableString *cellText = [[NSMutableString alloc] initWithString:@""]; // the cell is a section cell if (/* some condition */) { cellTe...

NSView background image composed of 3 different files.

Hi, I'm trying to set a background image of an NSView. (Actually an NSScrollView.) At the moment I'm subclassing drawRect: and I'm using NSDrawThreePartImage to draw the image but there are a few things that are not correct whenever I start scrolling. Here's an image. Are there better ways to draw the images? - (void)drawRect: (NSRect)...

resolution from a PDFPage?

I have a PDF document that is created by creating NSImages with size in 72dpi pts, each has a single representation which is measured in pixels. I then put these images into PDFPages with initWithImage, and then save the document. When I open the document, I need the resolution of the original image. However, all of the rectangles that ...

Why does MPMoviePlayerController work in the simulator, but not the device?

Hey guys, I'm having trouble getting MPMoviePlayerController to work on the device. It runs fine in simulator, playing a five-second video and then sending the appropriate callback (myMovieFinishedCallback:) to the view controller. When it runs on the device, the movie never shows up, even though I can trace through [player play] with n...

Optimize memory consumption when gradually writing to a file

Hi! I've been doing some tests, and one of my needs is to read data from different xml files and stack it together on a single file. While I've managed to accomplish this, memory consumption seems to be quite large for the task, the iphone simulator didn't even raise the memory warning, but I don't think the real iPhone would tolerate th...

Typecasting a TableViewController Class

I'm having a problem with either typecasting or object scope. I'm getting an uncaught exception: // Create the object here so that it's scope is outside the `if` statement, right? searchTableViewController *newViewController; if (rowSelected) { // Typecast the object to a searchTableViewController (searchTableViewController *)...

Accessing UIView methods

Howdy, I have a UIViewController that contains a UITabBarController, which contains a UIViewController, e.g.: UIViewController1 -> UITabBarController -> UIViewController2 I want to hook up a button in UIViewController2 that will call a method in UIViewController1, but how do I access UIViewController1 from UIViewController2? I know ...