-1

NSString名前付き *strKeyのインスタンスを宣言し、それに@synthesize1 つの文字列値を渡します。

しかし、その文字列を別のクラスに送信したいとき。それは私にエラーを与えています

ここに画像の説明を入力

これが私のコードです

ここで strKey に 1 つの値を割り当てます

 -(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];
    }

ここで何が欠けていますか?

4

1 に答える 1

2

initWithFormat解放する責任がある返されたオブジェクトを所有してstringWithFormatいますが、自動解放された文字列を返す返されたオブジェクトを所有していないため、解放する必要はありません (所有権を持ちたい場合は、保持する必要がありますそれ)。

したがって、問題を解決するには、次のように値を割り当ててみてください。

strKey=[[NSString alloc] initWithFormat:@"%d",[sender tag]];
于 2013-03-01T06:14:12.183 に答える