NSString *dateString=[[NSString alloc]initWithFormat:@"%@",[timeit objectAtIndex:indexPath.row]];
Asked
Active
Viewed 1,326 times
-7

rmaddy
- 314,917
- 42
- 532
- 579

user3354963
- 1
- 5
-
what you want exactly? – Dhaval Bhadania Mar 03 '14 at 07:07
-
and why you alloc string there is no need it. – Dhaval Bhadania Mar 03 '14 at 07:07
-
2What kind of object are you getting from the array? – rmaddy Mar 03 '14 at 07:09
-
3That depends on the type of objects that exist in your array. – Merlevede Mar 03 '14 at 07:09
-
thank u any way sorry for annoying , this code work correctly when array includes are strings , but it's doesn't work when array are dates of time , so what could i do please , i need to get my date array as strings – user3354963 Mar 03 '14 at 07:14
-
1Your code works for any object. Though you should never do this for anything except debugging. If you want to convert dates, use `NSDateFormatter`. – rmaddy Mar 03 '14 at 07:15
-
this is my code of dates array and i want this array display as subtitle on table view cell . – user3354963 Mar 03 '14 at 07:19
2 Answers
0
Try this: NSString *dateString=[array objectAtIndex:indexPath.row];
Is it working?
-
Your welcome. We are always here to help others and getting help too :) – Gaurav Mar 03 '14 at 07:10
-
sorry for annoying , this code work correctly when array includes are strings , but it's doesn't work when array are dates of time , so what could i do please , i need to get my date array as strings – user3354963 Mar 03 '14 at 07:12
-
try my new edited code. StringWithFormat is used to convert any object into String – Mohit Mar 03 '14 at 07:15
-
Please check out Convert NSDate to NSString: http://stackoverflow.com/questions/576265/convert-nsdate-to-nsstring – Gaurav Mar 03 '14 at 07:17
-
-
-4
no need to alloc and init
NSString *dateString=[NSString StringWithFormat:@"%@", [timeit objectAtIndex:indexPath.row]];

Mohit
- 3,708
- 2
- 27
- 30
-
1This assumes the array contains an `NSString` object. We don't know if that is true or not. – rmaddy Mar 03 '14 at 07:10
-
-
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
-
-
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
-
-
1That 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
-
-
@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
-
-
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