2

I just started saving sceenshots of my current application. Instead of giving the screenshots names beforehand I'd like to use the current date+ time (something unique) as the filename. I found a method timeIntervalSince1970 in objective C but it doesn't seem to exist in C4. So is there some other function that would return the current date?

suMi
  • 1,536
  • 1
  • 17
  • 30
  • Also, C4 is Objective-C so anything you can do in ObjC you can also do in C4. Things like NSDate, NSString, and some other basic objects are perfect on their own, so we haven't "C4'd" them. – C4 - Travis Oct 21 '13 at 17:16
  • Thanks Travis! I know I just couldn't make it work which was basically I didn't know which identifier to use in the string to identify the date ("%@") – suMi Oct 21 '13 at 19:29

1 Answers1

2

timeIntervalSince1970 is a class method of NSDate. If you want to get the current time every screenshot you can use as a unique identifier you can do something like this.

NSString * s = [NSString stringWithFormat:@"awesomeshot%@.jpg", [NSDate date]];
C4Log(@"%@",s );

If you really want to use timeIntervalSince1970 you can check out this discussion: How to convert NSDate into unix timestamp iphone sdk?

Community
  • 1
  • 1
Adam Tindale
  • 1,239
  • 10
  • 26