Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to sort plist by its value
    primarykey
    data
    text
    <p>I have Plist with list with List of Dictionaries(item0,item1,item2).and I populate this plist in the Graph..its works fine.and in Plist <code>key (date)-&gt; Value(i store by using NSDate)</code> .Now I need to sort the Plist in such a way that:- <code>graph</code> should display for only one week. say if first value is <code>26-Dec-12</code> than only upto <code>1-Jan-13</code>(1 week) values plist should display</p> <p><img src="https://i.imgur.com/Q5in0.png" alt="first"> .</p> <p><strong>code</strong> :</p> <pre><code>- (NSArray *)readFromPlist { // get paths from root direcory NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [documentPaths objectAtIndex:0]; NSString *documentPlistPath = [documentsDirectory stringByAppendingPathComponent:@"calori.plist"]; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:documentPlistPath]; valueArray = [dict objectForKey:@"title"]; return valueArray; } </code></pre> <p>and</p> <pre><code>- (void)drawRect:(CGRect)rect { // Drawing code CGContextRef _context = UIGraphicsGetCurrentContext(); ECGraph *graph = [[ECGraph alloc] initWithFrame:CGRectMake(10,10, 480, 320) withContext:_context isPortrait:NO]; NSMutableArray *Array=[NSMutableArray arrayWithArray:[self readFromPlist]]; NSMutableArray *items = [[NSMutableArray alloc] init]; for (id object in [Array reverseObjectEnumerator]){ if ([object isKindOfClass:[NSDictionary class]]) { NSDictionary *objDict = (NSDictionary *)object; tempItemi =[[ECGraphItem alloc]init]; NSString *str=[objDict objectForKey:@"title"]; NSLog(@"str value%@",str); float f=[str floatValue]; NSString*str1=[objDict objectForKey:@"date"]; NSLog(@" str values2-- %@",str1); tempItemi.isPercentage=YES; tempItemi.yValue=f; tempItemi.name=str1; [items addObject: tempItemi]; } } [graph drawHistogramWithItems:items lineWidth:2 color:[UIColor blackColor]]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload