cocoa-touch

How to read a NSDate in from a string?

I have strings with dates, and want to parse these into NSDate objects. Is there a way to do that? I've looked at NSDate and NSScanner, and haven't seen anything that would read it in from a string. ...

Is there a class or library for creating calendars?

I need a calendar in my app where the user can pick a date from. I wonder if there's a calendar library to do something like this? ...

Time Touch Events Take in iPhone SDK

Hi Everyone: I am wondering how I would go about measuring the time in between touches inside a view in the iPhone SDK. I know that the first event triggered is touchesBegan: and then the last one triggered is touchesEnded:, however I just don't know how I would go about measuring the time that the user has touched the view for. For i...

Arguments in @selector

Is there any way that I can pass arguments in selector? example: I have this method - (void)myMethod:(NSString*)value1 setValue2:(NSString*)value2{ } and I need to call this function through a selector passing two arguments. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(/*my method*/) userInfo:nil repe...

Rotate UIView in Cocoa Touch

Hi Everyone: I have seen other people who have had this question, but most of the responses aren't working on the latest 3.0 build of iPhone OS. Anyway, I'm wondering how I can programatically rotate a UIView without any input from the accelerometer. The code I have found so far: CGAffineTransform transform = CGAffineTransformMakeRot...

Strange UIImage positioning problem

I created a view in Interface Builder with a bunch of labels and an image. When I pushed the view onto a UINavigationController, it worked perfectly. I then inserted the view into a UITableView as a cell (instead); in order to do so, I had to convert change the superclass of its view controller from a UIViewController to a UITableViewC...

How to validate a given date in a specific calendar system from a string?

I have some dates represented as strings. These strings correspond to a date format of a particular locale and calendar system, i.e. Gregorian, Jewish, etc. In theory, I could try to use NSDateFormatter for this, but: 1) How does NSDateFormatter know in which calendar system the string date is expressed? 2) How does NSDateFormatter kno...

Is it possible to figure out the order of NSDateComponents objects for a specific locale and calendar system?

Example: An user has the US locale activated in the device and wants to enter a Jewish date. So the user uses the Jewish calendar system. As far as I get it, I can instantiate an NSCalendar with Jewish calendar system while still using the user's locale for the date+time format and other things. But how could I figure out the order of ...

Guess encoding when creating an NSString from NSData

When reading an NSString from a file I can use initWithContentsOfFile:usedEncoding:error: and it will guess the encoding of the file. When I create it from an NSData though my only option is initWithData:encoding: where I have to explicitly pass the encoding. How can I reliably guess the encoding when I work with NSData instead of files...

How to read the useres preferred date+time format?

I need a representation of the current user's preferred date+time format, like for example: @"yyyy-MM-dd'T'HH:mm:ssZ" Or in other words: When I print out a NSDate nicely compatible to the preferred locale of the user, then I need that format in string representation as Unicode Standard symbols like in the example above. Is there a way t...

How to print out dates nicely, depending on thre user's locale and calendar?

Imagine a user with a French locale, who prefers an Islamic calendar. How could I print this date nicely as string in such a way, that it matches the user's locale, but where the date+time information matches also the calendar? I believe that both the locale and the calendar have effect on how to format a day. Not the locale alone. Mayb...

Is it possible to create an own calendar system in cocoa touch / UIKit?

There are some constants for NSLocale, like NSJapaneseCalendar, but what if I wanted to create a "Physical Calendar" or something that isn't there? Is there a way to define an arbitrary calendar system and then use that with NSDate, NSDateComponents and NSCalendar? ...

Creating a unique id for a Core Data program on the iPhone

I am fairly new at programming in Objective-C, having been a windows programmer since I was a kid. I am falling in LOVE with it. I am, however, having a bit of trouble figuring out this Core Data stuff. How do I create a new entry with a unique ID? In SQL I would just declare one field as an autoincrement field. I'm not seeing anyth...

NSKeyedUnarchiver unarchiveObjectWithFile: returns nil in init: method

Update: This works if I call archiveRootObject: from applicationDidFinishLaunching:. If I call it from the init: method of a singleton class, it returns nil. I'm very confused by the behavior of NSKeyedUnarchiver unarchiveObjectWithFile:. The documentation says that it will return nil if the file doesn't exist. With one of my objects, t...

How to get a Unicode Standard (or other) string representation of the user's date+time format?

I can print out a date nicely based on the user's locale. But how could I get a string with the date+time format? ...

How to print all available information of a locale?

The locale object must contain more information than apple talks about in the documentation. i.e. it must contain several date format strings. How can I print all this stuff to see where they are? Is there a method that would print out all information about an object? ...

How to compute the order of NSDateComponents objects for a given date format?

I have an date format in a string, like this: @"M/d/yy h:mm a" Now I want to create text input fields for every component of that date, in the order of the given format above (which may vary depending on the locale. Are there methods or ways to analyze this date format in such a way that the order of the date format components can be...

How to figure out at which position a string contains another string?

Is there a method that could tell for a string like "foo bar Foo Bar one two three" at which position the string "Foo" is contained, case sensitive? ...

Why is my sizeWithFont:constrainedToSize:lineBreakMode: always returning zero?

I'm trying to make a UITableViewCell that adjusts its height based on the length of a string it's displaying, but am getting hung up on this method. Here's what I've got: NSString *text = @"A really long string in here"; CGSize theSize = [text sizeWithFont:[UIFont boldSystemFontOfSize:18.0f] constrainedToSize:CGSizeMake(265.0f, MAXFLOA...

Get tableView:heightForRowAtIndexPath: to happen after tableView:cellForRowAtIndexPath: ?

I've got some UITableViewCells that need to change their height depending on the length of the strings inside. I'm calculating the necessary height inside tableView:cellForRowAtIndexPath:, and then storing it in a variable (self.specialRowHeight). Then I've got: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIn...