【问题标题】:iPhone SDK errors in XcodeXcode 中的 iPhone SDK 错误
【发布时间】:2011-07-28 07:03:33
【问题描述】:

如何解决这些错误? :(
错误旁边的cmets

谢谢!

AuthenticationViewController.h

#import <UIKit/UIKit.h>

@interface YourViewController : UIViewController {
    NSMutableData *dataWebService;
}

AuthenticationViewController.m

#import "AuthenticationViewController.h"

@implementation AuthenticationViewController 

//缺少@end

- (void)viewDidLoad 

//预期的';'方法原型之后

{
    [super viewDidLoad];
    NSString *yourPostString = [NSString stringWithFormat:@" write here your SOAP Message or JSON input (depend on your webservice)"];

    dataWebService = [[NSMutableData data] retain];

    NSMutableURLRequest *request = [[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.yoursite/webService"]] retain];

    NSString *postLength =  [NSString stringWithFormat:@"%d", [yourPostString length]];

    [request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];

    [request addValue:postLength forHTTPHeaderField:@"Content-Length"];    

    [request setHTTPMethod:@"POST"];

    [request setHTTPBody:[yourPostString dataUsingEncoding:NSUTF8StringEncoding]];

    NSURLConnection *myConnection = [NSURLConnection connectionWithRequest:request delegate:self];

    [myConnection start];    

}


- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    [dataWebService setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [dataWebService appendData:data];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

    NSString *responseString = [[NSString alloc] initWithData:dataWebService encoding:NSUTF8StringEncoding];

    NSLog(@"Response: %@",responseString);

    [responseString release];

    [dataWebService release];

}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    NSLog(@"Eror during connection: %@", [error description]);

} 

//缺少@end

错误日志

编译C 构建/iPhone.build/Debug-iphonesimulator/iPhone.build/Objects-normal/i386/AuthenticationViewController.o “iPhone Sample/AuthenticationViewController.m”正常 i386 目标-c com.apple.compilers.llvm.clang.1_0.compiler cd /Users/Desktop/ASI/pokeb-asi-http-request-57f7ff2 setenv LANG en_US.US-ASCII setenv PATH “/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin” /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -x 目标-c -arch i386 -fmessage-length=0 -pipe -fdiagnostics-print-source-range-info -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-变量 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -fexceptions -fasm-blocks -mmacosx-version-min=10.6 -gdwarf-2 -fvisibility=hidden -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=30103 -iquote "/Users/Desktop/ASI/pokeb-asi-http-request-57f7ff2/build/iPhone.build/Debug-iphonesimulator/iPhone.build/ASIHTTPRequest iPhone 生成的文件.hmap" “-I/用户/桌面/ASI/pokeb-asi-http-request-57f7ff2/build/iPhone.build/Debug-iphonesimulator/iPhone.build/ASIHTTPRequest iPhone-own-target-headers.hmap" “-I/用户/桌面/ASI/pokeb-asi-http-request-57f7ff2/build/iPhone.build/Debug-iphonesimulator/iPhone.build/ASIHTTPRequest iPhone-all-target-headers.hmap" -iquote "/Users/Desktop/ASI/pokeb-asi-http-request-57f7ff2/build/iPhone.build/Debug-iphonesimulator/iPhone.build/ASIHTTPRequest iPhone-project-headers.hmap" -F/用户/桌面/ASI/pokeb-asi-http-request-57f7ff2/build/Debug-iphonesimulator -I/用户/桌面/ASI/pokeb-asi-http-request-57f7ff2/build/Debug-iphonesimulator/include -I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/include/libxml2 -I/Users/Desktop/ASI/pokeb-asi-http-request-57f7ff2/build/iPhone.build/Debug-iphonesimulator/iPhone.build/DerivedSources/i386 -I/Users/Desktop/ASI/pokeb-asi-http-request-57f7ff2/build/iPhone.build/Debug-iphonesimulator/iPhone.build/DerivedSources -包括 /var/folders/Cs/CsqSKcbMEOC12Z96tZhqZ++++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/iPhone_Prefix-gdcjyckfdobukjghijdsfunokuto/iPhone_Prefix.pch -c "/Users/Desktop/ASI/pokeb-asi-http-request-57f7ff2/iPhone 示例/AuthenticationViewController.m" -o /Users/Desktop/ASI/pokeb-asi-http-request-57f7ff2/build/iPhone.build/Debug-iphonesimulator/iPhone.build/Objects-normal/i386/AuthenticationViewController.o

/Users/Desktop/ASI/pokeb-asi-http-request-57f7ff2/iPhone 示例/AuthenticationViewController.m:3:17:错误:缺少 @end @implementation AuthenticationViewController ^ /用户/桌面/ASI/pokeb-asi-http-request-57f7ff2/iPhone 示例/AuthenticationViewController.m:5:20:错误:预期的“;”后 方法原型 - (void)viewDidLoad ^ ; /用户/桌面/ASI/pokeb-asi-http-request-57f7ff2/iPhone 示例/AuthenticationViewController.m:56:5:错误:缺少 @end @end ^ 生成 3 个错误。

【问题讨论】:

  • 针对 stackoverflow 的新手的很好的书面问题。欢迎来到 SO。

标签: iphone web-services asihttprequest


【解决方案1】:

类的实现在块内完成

@implementation classname

@end

您忘记在 .m 文件的末尾添加 @end。

@interface 声明也是如此。

【讨论】:

  • 感谢 Praveen S,我在 .m 文件的底部添加了 @end ,它仍然显示相同的错误 :(
  • 你的标题怎么样?也将其添加到头文件中。您可以完全发布错误日志吗?它的简单错误。
  • 当然!一秒,我加进去。
  • 在你的头文件末尾添加@end。
  • 错误:使用未声明的标识符“dataWebService”和错误:在@interface 中没有为“AuthenticationViewController”声明超类
猜你喜欢
  • 2010-12-14
  • 1970-01-01
  • 2014-03-01
  • 1970-01-01
  • 2012-01-23
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 2013-03-12
相关资源
最近更新 更多