Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 目标C重新加载问题_Iphone_Objective C_Ios_Plist - Fatal编程技术网

Iphone 目标C重新加载问题

Iphone 目标C重新加载问题,iphone,objective-c,ios,plist,Iphone,Objective C,Ios,Plist,我有一个包含大量条目的图表。它使用plist中的For循环加载数据。意思是一个接一个。现在我想要这样一种方式,如果从中读取的数据大于6,那么应该取substringToIndex:2否则substringToIndex:6 但问题是:数据在plist中,并且一个接一个地获取。我希望如果大于6,那么它应该是substringToIndex:2,用于整数值,而不是下一个数值。但是如果大于6,我如何重新加载数据,以使substringToIndex:2的整数值成为substringToIndex:2

我有一个包含大量条目的图表。它使用plist中的
For
循环加载数据。意思是一个接一个。现在我想要这样一种方式,如果从中读取的数据
大于6
,那么应该取
substringToIndex:2
否则
substringToIndex:6

但问题是:数据在plist中,并且一个接一个地获取。我希望如果
大于6,那么它应该是
substringToIndex:2
,用于整数值,而不是下一个数值。但是如果大于6,我如何重新加载数据,以使
substringToIndex:2的整数值成为
substringToIndex:2

代码

- (void)drawRect:(CGRect)rect {

  int l=0;
  NSMutableArray *Array=[NSMutableArray arrayWithArray:[self readFromPlistForOneWeek]];
  NSMutableArray *items = [[NSMutableArray alloc] init];

  for (id object in [Array reverseObjectEnumerator]){

    if ([object isKindOfClass:[NSDictionary class]])
    {
        NSDictionary *objDict = (NSDictionary *)object;

        //problem part below 
           l++;
        if(l>6){
              str1=[str1 substringToIndex:2];
              tempItemi.isPercentage=YES;
              tempItemi.yValue=f;
              tempItemi.width=10;
              tempItemi.name=str1;      
              [items addObject: tempItemi];
          } else{
              str1 =[str1 substringToIndex:6];
              tempItemi.isPercentage=YES;
              tempItemi.yValue=f;
              tempItemi.width=10;
              tempItemi.name=str1;
              [items addObject: tempItemi];
          }
     }
这给了我这样的输出


这里,如果值大于6,则应使用substringto索引:2表示所有..不仅对于大于6的值(不是图像中的最后2个)如果(l>6)
,则不必使用
。你可以直接使用

if ([Array count] > 6)

上面的代码将不起作用,因为您正在循环中递增它,并在递增时检查它。您需要对照数组的计数进行检查。

如果(l>6)
,则不必使用
。你可以直接使用

if ([Array count] > 6)

上面的代码将不起作用,因为您正在循环中递增它,并在递增时检查它。您需要对照数组的计数进行检查。

l是什么?什么应该超过6?我忘了增加我的代码。现在检查它的
l++
和l是计算值…如果plist值大于6,则需要substringto索引:2为什么不检查
如果([Array count]>6)
?l是什么?什么应该超过6?我忘了增加我的代码。现在检查它的
l++
和l是计算值…如果plist值大于6,则需要subStringToIndex:2为什么不检查
如果([Array count]>6)