开发者

A very strange query

I am new in objective c,well I am trying to develop an application.I have an nsdictionary in which I am storing three dates,yesterdays ,todays and next day.Well I am getting my google weather contents parsed in that nsdictionary.Now here the trouble begins...I have to sort my weather elements out based on the dates....dic is :

  got {
ConditionDatenew = "2011-07-20 13:36:01 +0000";
Yesterday = "2011-07-19 13:36:01 +0000";
city = #;
condition = "Partly Cloudy";
country = #;
"day_of_week" = Sat;
high = 93;
icon = "partly_cloudy.gif";
low = 76;
newdate = "2011-07-22 13:12:01 +00开发者_StackOverflow00";
state = #;

Thats my NSDictionary above ...I have to sort my weather elemets out based on the dates and store them in coredata..which I am able to do it..I am not being able to sort things out a...can anyone help me in doing so?


  1. Iterate through the weather object to split the date string into char objects.
  2. Then use the NSNumber class to do the work of sorting:

    myNum = [NSNumber numberWithChar: '2'];

    NSLog(@"%c", [myNum charValue]);


You can make the date into an NSDate object and then use the instance method -compare: You could also use the methods -earlierDate: and -laterDate: to see whether a particular date is earlier or later than another one.

Here is the documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜