objective-c

Cast an instance of a class to a @protocol in Objective-C

I have an object (a UIViewController) which may or may not conform to a protocol I've defined. I know I can determine if the object conforms to the protocol, then safely call the method: if([self.myViewController conformsToProtocol:@protocol(MyProtocol)]) { [self.myViewController protocolMethod]; // <-- warning here } However, XC...

How to use scroll view on iPhone?

I want to display a text with a lot of lines. I added a multiline-label to a scroll view, but it didn't show anything. Looks like this is not the correct way to use the scroll view. How to use scroll view so that users can drag down to see more text? ...

Adding Icon on desktop of iPhone

Hi, I want to place an icon on the iPhone screen form my application, like placing an icon and if i will touch that icon it will do the desired operation, like opening a sound file or an image. So i want to ask is it possible to place an icon on screen through an application and do some events on it. Regards, Vishal ...

Compiling in Xcode fails because linked lib isn't found

Hello, I need the openssl lib for some C code in my iPhone App. So I've put the lib into my project. But when I compile it, Xcode throws me some errors: error: openssl/ssl.h: No such file or directory That's my code for including: #include <openssl/ssl.h> Target settings in Xcode: Which step am I missing to link it correct...

Searching text from UITextView in iPhone

I'm developing an application for the iPhone where some text is shown in a UITextView. I want to search for a specific word in the text and then show the text with that specific word colored. If anyone can help me solve this, I'll be very glad. ...

Lock orientation UIWebView on iPhone

Is there a way to lock the orientation of a UIWebView? With Obj-C, JS, or Html? I don't want to have a button or anything I just want it to be locked to portrait as soon as the app opens up. ...

Receiver 'ClassName' is a forward class and corresponding @interface may not exist

Im currently trying to find a UIPickerTable within the UIPickerView.subviews ... so i loop through and do isKindOfClass:[UIPickerTable class] .... which works.. but because the header of UIPickerTable isn't exposed i get a warning that "receiver 'UIPickerTable' is a forward class and corresponding @interface may not exist' In order ...

Looking for a simpler Objective-C solution

Maybe simpler isn't the proper word; terse might do as well. I'm well-aware that Objective-C is a verbose language; I'm just wondering if it has to be as verbose as it is in the solution I'm showing below. I'm relatively new to the language. This piece of code counts the number of each type of field in a record, pursuant to generating a...

Objective C IBOutlets

In cases where multiple buttons call an IBOutlet, can the IBOutlet determine which button was pressed? edit: All fixed and wired up. key point: Object ID is not sender tag! Tag is a standalone value on the first page of the attributes. - (IBAction)buttonPressed:(id)sender { switch ( [sender tag] ) { case 109: ...

Cocoa QTKit and recording movies

I'm new with the whole QTKit and I was looking for some feedback on the following code that I am attempting to use to display the camera's image and record movies. - (void)initializeMovie { NSLog(@"Hi!"); QTCaptureSession* mainSession = [[QTCaptureSession alloc] init]; QTCaptureDevice* deviceVideo = [QTCaptureDevice defaultInputDevi...

How to create an Instance Variable in Objective-C

I have this example, and I would like to make my_Picture an instance variable in order to use removeFromView. Any Ideas? I got all kinds of warnings and errors trying different approaches. Thank you in advance - (void) viewDidLoad { UIImageView *my_Picture = [[UIImageView alloc] initWithImage: myImageRef]; [self.view addSubview:my...

Cocoa without Interface Builder, initialize an instance of app controller?

I don't plan to write applications without IB, I'm just in the process of trying to learn more about programming. How can I get a single instance of my AppController class at startup? (It's normally loaded from the nib.) And can you clear up the use of +initialize and -init? If I understand, +initialize is called on all classes at sta...

How to ALTER sqlite column (iPhone)?

For the iPhone, since sqlite3 doesn't support ALTER for a column, how do I change the data type of a column on a table that needs to preserve its data? ...

Segmentcontrol Color on load?

Hi PPL :) I am having some trouble with my segmentcontrol bar. I am trying to make it a gray/black color with this: segmentControl3.tintColor = [UIColor colorWithRed:0.60 green:0.60 blue:0.60 alpha:1.0]; Under my getSegment action, and that works just fine when I click it. But my problem is that the load color is the standart blue one...

How to escape characters in href=mailto (iPhone)

I want to create a link on a UIWebView that emails content to the user. A simple example is: <a href="mailto:[email protected]?subject=Sarcasm&body=I » <b>love</b> &lt;html&gt; mail!">Hi!</a> Which creates a message that looks like this: -- begin message --- To: [email protected] Subject: Sarcasm I love mail! -- end message -- ...

Cocoa/Objective-C NSProcessInfo weirdness...

So I've just started digging into Objective-C, Cocoa, and iPhone development. I've ran into a little weird thing which I don't really get tho. I'm trying to get process information, process name works fine, but things get weird when I try to also get the process ID. Here's the piece of code I have, which evidently doesn't output anythi...

Weird build error, problem with class name?

I'm doing a short project just to experiment writing without the use of nib files (personal interest only, don't plan on never using nibs!). I have my app controller set up as NSApp's delegate. Under -(void)applicationDidFinishLaunching:(NSNotification *)aNotification, I attempt to initialize the interface. AppController.h: #import <C...

changing constants for unit tests

Hi there, I'm writing some unit tests in cocoa for a data driven application. I've got a constants header file which defines a whole heap of variables including paths to the databases etc. I was wondering if it's possible to get all the classes to use a different set of constants which would link to a testing version of the database e...

Determining the usable area of an UIView

Hello all, I'm an iPhone dev newbie, and I'm running into a problem figuring out how much of an UIView I'm able to use when the UIViews's controller is part of an UITabController. I'm initializing the window as window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; and the view as myView = [[UIView alloc] initWith...

UIView - draw Images - tile based game

Hello, i am trying to create a simple puzzle game.. and i have an int[8][8] array that reprents the map.. each cell has a value which represents some item. now i want to draw this map on the screen, i have an image file for each item. (each item has the same width and height) i tried to do this with creating a UIImageView for each cel...