Witam
Ten kod kompiluje się bez problemu, natomiast wywala się podczas uruchomienia:Kod:#import#import int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // insert code here... // Ładowanie szablonu dokumentu HTML DOMDocument *dok = [[DOMDocument alloc] init]; [dok setDocumentURI:@"/Pro1/szablon_prosty.html"]; DOMHTMLElement *cielsko = [[DOMHTMLElement alloc] init]; [dok setBody:cielsko]; cielsko.idName=@"cielsko"; DOMCSSStyleDeclaration *stylik = [[DOMCSSStyleDeclaration alloc] init]; [stylik setBackground:@"red"]; [[dok getElementById:@"cielsko"] setAttribute:@"style" value:@"stylik"]; NSString *dokString = [dok stringRepresentation]; //zamieniam dokument na NSString const char *cString = [dokString cStringUsingEncoding:NSUTF8StringEncoding]; //c string printf("Content-Type: text/html\n\n"); //standardowy nagłówek i treść printf("%s",cString); [pool drain]; return 0; }
Rozumiem że linia:2010-08-04 08:16:28.779 Pro2[3534:903] *** Terminating app due to uncaught exception 'NSGenericException', reason: '+[DOMDocument init]: should never be used'
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff872edcc4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff80e390f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff872edae7 +[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x00007fff872eda74 +[NSException raise:format:] + 148
4 WebCore 0x00007fff838c3e7b -[DOMObject init] + 75
5 Pro2 0x0000000100000cd5 main + 113
6 Pro2 0x0000000100000c5c start + 52
)
terminate called after throwing an instance of 'NSException'
Abort trap
logout
jest źle,tylko jak zainicjować ten element?Kod:DOMDocument *dok = [[DOMDocument alloc] init];
---------- Wpis dodano o 08:40 ---------- Poprzedni wpis dodano o 08:21 ----------
Przyjrzałem się dokumentacji i chyba rozumiem:
Trzeba najpierw stworzyć WEBFrame następnie korzystając z metody DOMDocument utworzyć ten obiekt.Tak?



LinkBack URL
About LinkBacks
Cytuj