2013-04-09 77 views
0

我是这个mac应用程序开发的新手。EXC_BAD_ACCESS类型NSString的错误

该应用程序正常工作的一些数据和应用程序崩溃的条目。

-(void)presentClientsss 
{ 
    [productVendorTextField setStringValue:[NSString stringWithFormat:@"%@", [[popUpVendor selectedItem] title]]]; 

    NSMenuItem *tempMenuItem = [popUpVendor selectedItem]; 
    NSString *selectedItemTitle = [tempMenuItem title]; 

    for (int k = 0; k < [appDelegate.vendorInfoArr count]; k++) 
    { 
     VendorInfo *tempCustomerInfoModel = [appDelegate.vendorInfoArr objectAtIndex:k]; 

     if ([tempCustomerInfoModel.vendorName isEqualToString:selectedItemTitle]) 
     { 
      oldVendorIde = [NSString stringWithFormat:@"%ld", tempCustomerInfoModel.rowId]; 

      NSLog(@"Selected RowID = %@",oldVendorIde); 

      break; 
     } 
    } 
} 

我发送oldVendorIde字符串到下一个方法。

- (ItemModel *)itemNodelWithAttributes { 
    isProductIdExist = NO; 

    if ([senderInfo isEqualToString:@"nP"]) { 
     for (int i = 0; i < [appDelegate.itemsArr count]; i++) { 
      ItemModel *tempIM = [appDelegate.itemsArr objectAtIndex:i]; 
      if ([tempIM.productId isEqualToString:[[productIdTextField stringValue] uppercaseString]]) { 
       isProductIdExist = YES; 
       break; 
      } 
     } 
    } 

    if ([senderInfo isEqualToString:@"eP"]) { 
     for (int i = 0; i < [appDelegate.itemsArr count]; i++) { 
      ItemModel *tempIM = [appDelegate.itemsArr objectAtIndex:i]; 
      if (tempIM.itemId == itemIdentity) { 
       if ([tempIM.productId isEqualToString:[[productIdTextField stringValue] uppercaseString]]) { 
        isProductIdExist = NO; 
       } 
      } 
      else if ([tempIM.productId isEqualToString:[[productIdTextField stringValue] uppercaseString]]) { 
       isProductIdExist = YES; 
      } 
     } 
    } 
    int tempItemExists = [self saveProductImage:[[productIdTextField stringValue] uppercaseString]]; 

    NSLog(@"oldVendorIde =%@",oldVendorIde); 
    ItemModel *iM = [[ItemModel alloc] initWithItemId:itemIdentity defaultItemMinimumValue:[productMinValueTextField floatValue] staticItemPrice:[productPriceTextField doubleValue] dynamicItemQuantity:[productCurrentStockTextField doubleValue] staticItemDescription:[productDescriptionTextField stringValue] prodId:[[productIdTextField stringValue] uppercaseString] itemVendor:oldVendorIde itemImgExists:tempItemExists stockAvailable:0 itemNotes:[notesTextField string] BarcodeDesc:[BarcodeDescTextView stringValue]]; 

    return iM; 
} 

在这种方法同样oldVendorIde工作正常了一些数据,有些时候它就会在这一点上坠毁。

oldVendorIde有时在itemNodelWithAttributes方法中没有得到任何值,并且该应用在该点崩溃。

曾根能帮我解决这个问题..谢谢提前..

回答

0

UITextField文本通过text属性([productIdTextField text])访问,而不是通过stringValue

+0

这将是一个'NSTextField'而不是'UITextField',但是相同的交易。 – dreamlax 2013-04-09 10:36:18