-7
NSString *dateString=[[NSString alloc]initWithFormat:@"%@",[timeit objectAtIndex:indexPath.row]];
rmaddy
  • 314,917
  • 42
  • 532
  • 579

2 Answers2

0

Try this: NSString *dateString=[array objectAtIndex:indexPath.row];

Is it working?

Sport
  • 8,570
  • 6
  • 46
  • 65
Gaurav
  • 299
  • 4
  • 15
-4

no need to alloc and init

NSString *dateString=[NSString StringWithFormat:@"%@", [timeit objectAtIndex:indexPath.row]];
Mohit
  • 3,708
  • 2
  • 27
  • 30
  • 1
    This assumes the array contains an `NSString` object. We don't know if that is true or not. – rmaddy Mar 03 '14 at 07:10
  • yes thats right. then try my new edited answer – Mohit Mar 03 '14 at 07:11
  • Now you are simply repeating the code the OP had. What's the point of that? – rmaddy Mar 03 '14 at 07:12
  • thank uu, also i need to gets my array that have dates , so what could i do please :) – user3354963 Mar 03 '14 at 07:16
  • 1
    Down voter what is your problem man?? – Mohit Mar 03 '14 at 07:16
  • @user3354963 did you down vote it?? – Mohit Mar 03 '14 at 07:17
  • I donwvoted because your answer simply repeats the code in the original question. There is no point to such an answer. – rmaddy Mar 03 '14 at 07:19
  • just check it man he is allocing and init the string and i have used StringWithFormat method – Mohit Mar 03 '14 at 07:19
  • this two are totally different things. just check it – Mohit Mar 03 '14 at 07:20
  • 1
    That doesn't matter. It still does the same thing. Calling `stringWithFormat:` is the same as calling `alloc/init/autorelease`. The end result is the same, especially under ARC. – rmaddy Mar 03 '14 at 07:20
  • of course no i did check mark am new on stackover flow i don't have permission to make vote ,Mr @mohitpopat , really thank uuu , i never make vote down for any one help me – user3354963 Mar 03 '14 at 07:33
  • its ok is it worked for you? – Mohit Mar 03 '14 at 07:34
  • @user3354963 no need to say thank you. i m here to help others and to learn something new. – Mohit Mar 03 '14 at 07:37
  • thank it's work in array includes string but does not work on array include dates . – user3354963 Mar 03 '14 at 07:40
  • his is my code of dates array and i want this array display as subtitle on table view cell . – user3354963 Mar 03 '14 at 07:41
  • ok do you wants full date (date & time) or you need only date?? – Mohit Mar 03 '14 at 07:42
  • NSMutableArray*timeit=[NSMutableArray arrayWithObject:[NSDate date]]; NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSString *plistPathTime=[documentsPath stringByAppendingString:@"Data.plist"]; [timeit addObjectsFromArray:[NSMutableArray arrayWithContentsOfFile:plistPathTime]]; [timeit writeToFile:plistPathTime atomically: YES]; – user3354963 Mar 03 '14 at 07:42