不是你通常的'Class'可能不响应'方法'警告 - iPhone / Objective-C

时间:2010-11-26 11:08:59

标签: iphone objective-c xcode warnings


我知道你一定已经看过这个警告并经常给出解决方案,但我的情况有点特别 我只收到一个类的警告,但是所有内容(导入,实现,头文件等)都设置正确。我现在在XCode中对Objective-C进行编码已经有一段时间了,并且我会说,我已经获得了很多iPhone编程的经验。我完全相信,一切都很好 看来,XCode不知何故没有认识到我对班级做出的改变。它甚至建议一些不再属于这个类的方法。我在另一个mac上检查了项目并在那里构建它,一切都很好,没有任何警告。
我不想重新安装XCode来摆脱那些不应该存在的烦人警告。关于如何告诉XCode必须自己购买一些眼镜的任何建议? 非常感谢帮助=)

编辑:好的,只是为了没人能说,我疯了或者其他什么,最后是代码和一个小解释:

#import <Foundation/Foundation.h>


@interface URLConnection : NSObject {
NSString *theURL;
NSMutableData *receivedData;
id delegate; // delegate needed for handling response
}

@property (nonatomic, retain) NSMutableData *receivedData;
@property (retain) id delegate;

- (NSData*) sendSynchronousRequest:(NSData*)_postData;
- (void) sendRequest:(NSData*)_postData;

- (void)setDelegate:(id)val;
- (id)delegate;

@end

#import "URLConnection.h"


@implementation URLConnection

@synthesize receivedData, delegate;


- (id) init
{
if (self = [super init]) {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if (![[defaults stringForKey:@"bankurl"] isEqualToString:@"<Custom URL>"]) {
        theURL = [[defaults stringForKey:@"bankurl"] retain];
    } else {
        theURL = [[defaults stringForKey:@"bankurl_list"] retain];
    }
    receivedData = [[NSMutableData alloc] init];
}
return self;
 }

 - (void)setDelegate:(id)val
 {
    delegate = val;
 }

 - (id)delegate
 {
return delegate;
 }


 /* send a synchronous request (specified for xml documents) */
 - (NSData*) sendSynchronousRequest:(NSData*)_postData
 {
NSString *_urlString = theURL;
NSMutableURLRequest *_urlRequest = [[NSMutableURLRequest alloc] init];
[_urlRequest setURL:[NSURL URLWithString:_urlString]];
[_urlRequest setHTTPMethod:@"POST"];
[_urlRequest setValue:@"text/xml" 
   forHTTPHeaderField:@"Content-Type"];
[_urlRequest setHTTPBody:_postData];

// response
NSHTTPURLResponse *_urlResponse = nil;
NSError *_error = [[NSError alloc] init];
NSData *_responseData = [NSURLConnection sendSynchronousRequest:_urlRequest 
                                              returningResponse:&_urlResponse 
                                                          error:&_error];
[_urlRequest release];
NSString *_result = [[NSString alloc] initWithData:_responseData 
                                          encoding:NSUTF8StringEncoding];
NSLog(@"Response code: %d", [_urlResponse statusCode]);
if ([_urlResponse statusCode] >= 200 && [_urlResponse statusCode] < 300) {
    NSLog(@"Response: %@", _result);
}
return _responseData;
}


/* send an asynchronous request (specified for xml documents) */
- (void) sendRequest:(NSData*)_postData
{
NSMutableURLRequest *_urlRequest = [[NSMutableURLRequest alloc] init];
[_urlRequest setURL:[NSURL URLWithString:theURL]];
[_urlRequest setHTTPMethod:@"POST"];
[_urlRequest setValue:@"text/xml" 
   forHTTPHeaderField:@"Content-Type"];
[_urlRequest setHTTPBody:_postData];

[[NSURLConnection alloc] initWithRequest:_urlRequest delegate:self];
[_urlRequest release];
 }


 /* 
  * NSURLRequest Delegate
  * if a response comes back, clear receivedData to make room for the response data
  */
 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
 {
[receivedData setLength:0];
 }


/* 
 * NSURLRequest Delegate
 * if data is received, append the chunk of data to receivedData
 */
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[receivedData appendData:data];
}


/* 
 * NSURLRequest Delegate
 * when all response data has been stored, call didFinishDownload() in the class
 * which set itself as the delegate
 */
- (void)connectionDidFinishLoading:(NSURLConnection *)connection

{
[delegate didFinishDownload:receivedData];

[connection release];
//[receivedData release];
}



- (void) dealloc
{
[theURL release];
theURL = nil;
[super dealloc];
}

@end

首先,是的,我知道行“[delegate didFinishDownload:receivedData];”会发出警告,但这不是我正在写的问题。当我按下alt + esc查看方法建议时,以上所有内容都在列表中,还有“sendRequest:theURL:”和“sendMail:”,这些内容早已被删除。

4 个答案:

答案 0 :(得分:0)

你做过清洁所有目标吗? (它在Xcode的Build菜单中。)

答案 1 :(得分:0)

Xcode(应用程序菜单) - &gt;空缓存......

答案 2 :(得分:0)

- 从保存应用的文件夹中删除您的版本, - 从模拟器或设备中删除。 - 清洁所有目标。 - 点击xcode然后清空缓存...... 现在没有警告你会看到。

答案 3 :(得分:0)

您是否完全确定在您的计算机中某个地方找不到此标题的另一个副本,xcode可能会在找到您最新的副本之前找到它?