Arguments by reference in Objective-C

后端 未结 5 747
孤城傲影
孤城傲影 2020-12-09 04:18

I\'m trying to pass an NSString by reference but it doesn\'t work.

This is the function:

+(void)fileName:(NSString *) file
{
    file =          


        
5条回答
  •  情书的邮戳
    2020-12-09 04:44

    Try this

    +(void)filename:(NSString **)file {
         *file=@"folder_b";
    }
    

    and send the file as &file like:

    NSString *file;
    [function fileName:&file];
    nslog(@"%@",file);
    

    hope this will work.

提交回复
热议问题