Xcode 4 warning "Expression result unused” for NSURLConnection

后端 未结 3 730

I\'m just trying to do my usual data transfert. I define my NSMutableURLRequest then call

[[NSURLConnection alloc] initWithRequest:request delegate:self];

3条回答
  •  星月不相逢
    2020-12-04 11:37

    When a function returns a result that you don't need you can cast it to void to eliminate the compiler warning:

    (void) [[NSURLConnection alloc] initWithRequest:request delegate:self];
    

    I haven't used ARC yet so I can't say if this is a good idea, before ARC you would need to keep this pointer result somewhere so you could release it.

提交回复
热议问题