Tech Thought

Tech tips, hints, and general musings. PHP, Perl, Mysql, Javascript, AJAX, JSON, Linux, Mac OSX

Entries Tagged ‘objective-c’

How-To: Convert NSData to NSString

How do you convert an NSData object into it’s string representation?  Should be easy, right?  It is, when you know how… NSString* theString = [[NSString alloc] initWithData:theData encoding:NSASCIIStringEncoding];

Comments (1)

Objective-C: Calculating Days, Minutes, Hours from seconds

If you need to convert a total number of seconds into specific components (days, hours, minutes and seconds) in Objective-C, you can use this code snippet.  You can probably do this a million other ways, but this works beautifully for me:     NSNumber *valueForDisplay = [NSNumber numberWithDouble: [self valueForDisplay:clockName]];     NSNumber *totalDays = [NSNumber numberWithDouble: [...]

Comments (5)