NSString实例的<error:unknown =“”class =“”> </error:>

时间:2013-03-01 05:30:43

标签: iphone objective-c xcode ipad

我声明NSString名为* strKey和@synthesize的实例,我将一个字符串值传递给它。

但是当我想将该字符串发送到另一个类时。它给了我错误的

enter image description here

这是我的代码

在这里为strKey分配一个值

 -(IBAction)getLocal:(UIButton *)sender
    {
        [self startDeckDownload];
        GroupDeckExpandableViewObject *objConfiguration=[[GroupDeckExpandableViewObject alloc] init];
        GroupListCell *celltest=(GroupListCell *)sender.superview.superview.superview;

        if(celltest != nil){
            celltest.viewDownload.hidden =NO;
            celltest.viewGetLocal.hidden=YES;
            //objConfiguration.vwWelcome=celltest.viewWelcome;
            objConfiguration.vwGetLocal=celltest.viewGetLocal;
            objConfiguration.vwDownLoad=celltest.viewDownload;
            strKey=[NSString stringWithFormat:@"%d",[sender tag]]; // i am assign one value to the string here.
            [delegate setGroupViewConfiguration:objConfiguration withtag:[NSString stringWithFormat:@"%d",[sender tag]]];

        }

    }

传递给另一个类(使用协议)。

-(void)setDownloadProgress:(float)progress
{

    [delegate setDownloadProgress:progress withkey:strKey];
}

以下是协议方法的定义。

@protocol groupListCellDelegate<NSObject>

@optional
- (void) setGroupViewConfiguration:(id)objConfiguration withtag:(NSString *)key;
-(void)setDownloadProgress:(float)progress withkey:(NSString *)key;
@end

我在GroupView.m

中使用此方法
#pragma mark - delegate method

    -(void)setGroupViewConfiguration:(id)objConfiguration withtag:(NSString *)key
    {

        [arrGroupViewConfiguration setValue:objConfiguration forKey:key];
        GroupDeckExpandableViewObject *objgetviews=[arrGroupViewConfiguration valueForKey:key];
         [tblData reloadRowsAtIndexPaths:[NSArray arrayWithObjects:objgetviews.cellIndexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
     //   [tblData reloadData];
    }

    -(void)setDownloadProgress:(float)progress withkey:(NSString *)key
    {
        NSLog(@"Reloaded...");
        progress_percent = progress;
        GroupDeckExpandableViewObject *objgetviews=[arrGroupViewConfiguration valueForKey:key];
        NSLog(@"%d",objgetviews.cellIndexPath.section);
        [tblData reloadRowsAtIndexPaths:[NSArray arrayWithObjects:objgetviews.cellIndexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
      //  [tblData reloadData];
    }

我在这里缺少什么?

1 个答案:

答案 0 :(得分:2)

您拥有从您负责发布的initWithFormat返回的对象,但您不拥有从stringWithFormat返回的返回自动释放字符串的对象,因此不需要释放它(如果你想拥有它,你必须保留它。)

因此,要解决您的问题,请尝试分配您的值,

strKey=[[NSString alloc] initWithFormat:@"%d",[sender tag]];