objective-c

Movie Player Crashes Sometimes in Horizontal Orientation

MPMoviePlayerViewController* moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:myChartlyObj.video_url]]; moviePlayerViewController.view.backgroundColor = moviePlayerViewController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"st-screen.png...

NSURLConnection optimization

I'm trying to understand NSURLConnection performance on a 3G network from an iPhone. I have the following test code -(void)doTest2 { max = 5; NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; NSURLRequest *request2 = [[[NSURLRequest alloc] initWithURL:url] autorelease]; NSURLConnection *conn=[[NSURLConn...

Doubt in UITableView Cell Search functionality

Hey All, My iPhone application has a UITable View implemented with search functionality in it. The values in the table are grouped into sections from A-Z. Whenever a user tap on particular cell in the table it loads a detail view controller which gives all the values of that particular user. Now my problem is whenever I search some conta...

Dynamically create a NSString stringWithFormat: output

Hi, trying to figure out how to add zeroes in front of a random generated number with dynamic length of the number. For example if the number is 10 characters long, I can print the number as stringWithFormat:@"%.10d",i Since the numer can somtimes be shorter than maximum length, it needs zeroes to fill the maximum length of the numbe...

How to force horizontal orientation?

I want to do the following: ViewControllerA should not go into horizontal orientation ViewControllerA pushes ViewControllerB ViewControllerB should go into horizontal orientation. Not sure what to set to make this happen. ...

populating the plist

hi there, looking for some help.. i have 2 controllers, 1 contains a custom cell table. when user selected a cell, i will be display at the other controller. so far my approach is when at controller 1, if cell selected, save to plist, than at controller 2, load the plist. my saving and loading code: NSMutableArray *selectedData; sel...

Check NSString Contains Both Letters And Numbers

Hi I'm looking for the best way to check that an NSString contains both numerical and alphabetical characters. What I have come up with so far is the code below but his just tells me that now characters were entered which aren't number or letters. if( [[myNSString stringByTrimmingCharactersInSet: [NSCharacterSet alphanum...

Objective c - Sending a fixed amount of data over the socket ?

every time i am writing some data to my server i first send a message containing a number which is suppose to tell the server how much data i am going to send. For example before sending 1024 bytes, i need to first send the "1024" to the server then server can start reading for 1024 bytes. How can i make sure the first message (number o...

Class type Objective C

I am sorry if this has been asked before, I have looked throughout stackoverflow and haven't found an answer to this question. In the NSObject protocol, it defines a method that is similar to this: -(Class) class What type of object is the Class object? Or is it even an object? What can I do with the object? Can I get the base class ...

Object don't call the good controller.

In my apps, I have a toolBar with a button inside. When you pressed that button a actionSheet appear and you can change the langage of the apps. I want a put this toolBar in a lot of view, but I want to use the same object, not copy-paste in all my view. So I create a UIViewController with a nib file, this nib file containt my toolBar. N...

Best Persistence model for iPhone development

I'm finishing my second book on iPhone development (Beginning Iphone 3 Development - Mark/LaMarche) and, while this book covers the 4 main persistence mechanisms, I'm still not sure which one to use for my application. My data model is not very intricate, but I do need some relationship definition and functionality. So what are the sea...

2-dimensional arrays in Objective-C?

I'm working on a basic iPhone game that requires a single-screen tilemap. Nothing difficult there. I come from a C background, so my current solution looks a bit like this: typedef struct _Tile { NSString *type; } Tile; @interface Map { Tile mapData[MAP_TILE_MAX_X][MAP_TILE_MAX_Y]; } This works fine, but I'm wondering if ther...

Focus NSAlert accessory item

I have an NSAlert item that uses an NSTextField as an accessory item to provide an prompt-like dialog box. The only problem that I have is that when the alert is ran the text field is not focused. I tried looking for a way to change NSAlert's first responder but found nothing. Is there a way to easy focus an accessory item in NSAlert? ...

How does rand() work? Does it have certain tendencies? Is there something better to use?

I have read that it has something to do with time, also you get from including time.h, so I assumed that much, but how does it work exactly? Also, does it have any tendencies towards odd or even numbers or something like that? And finally is there something with better distribution in the C standard library or the Foundation framework? ...

custom button with multiple images

hi all, i have 3 images that i would like to use them to generate my custom button. my images are left.png 5x20, right.png 5x20 and mid.png 1x20. my mid.png must be repeated as long as my text lenght. how can i generate it in iphone application on the fly? thanks. ...

UIImage only loads on iPhone if I change file name to lowercase

I have an image that changes due to a button press. I have the code set up like this: UIImage *example = [UIImage imageNamed: @"Example.png"]; UIImage *stuff = [UIImage imageNamed: @"Stuff.png"]; UIImage *bob = [UIImage imageNamed: @"Bob.png"]; UIImage *thing = [UIImage imageNamed: @"thing.png"]; It used to be so that the last image ...

Problem creating UTF8 text file with NSFileHandle

I want to use NSFileHandle to write large text files to avoid handling very large NSString's in memory. I'm having a problem where after creating the file and opening it in the Text Edit app (Mac), it is not displaying the unicode characters correctly. If I write the same text to a file using the NSString writeToFile:atomically:encoding:...

NSWindowController: loadWindow loads window from nib but showWindow: does nothing

I have an NSWindowController subclass called _PreferencesWindowController with the following implementation - @synthesize window; - (id)init { self = [super initWithWindowNibName:@"PreferencesWindow"]; if (!self) return nil; return self; } And I tried to show the window in _PreferencesWindowController by using the following code...

Header Files Mystery

Possible Duplicate: what is the difference between #include <filename> and #include filename Why do we use Quotation Marks ("...") for custom build classes and braces for built in classes(<...>)? ...

bring touched views to the front layer in objective-c/cocoa touch

So what i want to do is when any given UIView is touched, and moved around the window, to bring that to the front and be on top of all other layers. is there a way to do this programatically? ...