Re: NSPropertyListSerialization
Re: NSPropertyListSerialization
- Subject: Re: NSPropertyListSerialization
- From: Kazutaka KAMIYA <email@hidden>
- Date: Mon, 19 May 2003 11:52:13 +0900
Hello,
Thanks. I did it!!
I am happy to use Cocoa-Java from WebObjects.
Points are...
1. add Cocoa.framework in my WOApp.
2. before use NSPropertyListSerialization, call NSAutoreleasePool.
below sample code.
try {
// Read
FileReader fr = new FileReader("/tmp/test.plist");
// Write
FileWriter fw = new FileWriter (new File
("/tmp/test2.plist"));
BufferedReader br = new BufferedReader(fr);
StringBuffer sb = new StringBuffer();
while(br.ready()){
sb.append(br.readLine());
}
String myStr = sb.toString();
// !!! NSData must new before NSAutoreleasePool !!! It raise exception
if it make after NSAutoreleasePool.
com.apple.cocoa.foundation.NSData cData = new
com.apple.cocoa.foundation.NSData(myStr.getBytes());
// AutoReleasePool push
int myPool =
com.apple.cocoa.foundation.NSAutoreleasePool.push();
com.apple.cocoa.foundation.NSData cDataW = new
com.apple.cocoa.foundation.NSData();
com.apple.cocoa.foundation.NSMutableArray myData = null;
myData =
(com.apple.cocoa.foundation.NSMutableArray)com.apple.cocoa.foundation.NS
PropertyListSerialization.propertyListFromXMLData(cData);
cDataW =
com.apple.cocoa.foundation.NSPropertyListSerialization.XMLDataFromProper
tyList(myData);
fw.write (new String(cData.bytes(0,cDataW.length())));
fw.close();
System.out.println("NSPropertyListSerialization"+myData);
com.apple.cocoa.foundation.NSAutoreleasePool.pop(myPool);
// AutoReleasePool pop
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
Thanks,
Kazutaka.
On 5 17, 2003, at 08:46 AM, Ricardo Strausz wrote:
See also
http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/
ProgrammingTopics/LanguageIntegration/Concepts/memory.html
Hope it helps!
On viernes, mayo 16, 2003, at 00:34 America/Mexico_City, Kazutaka
KAMIYA wrote:
Hello,
Thanks for advising me, again!
On , 5 16, 2003, at 06:25 AM, Art Isbell wrote:
On Wednesday, May 14, 2003, at 11:17 PM, Kazutaka KAMIYA wrote:
I tried to test adding NSAutoreleasePool, But It could not do it.
int myPool = com.apple.cocoa.foundation.NSAutoreleasePool.push();
<com.webobjects.appserver._private.WOComponentRequestHandler>:
Exception occurred while handling request:
com.webobjects.foundation.NSForwardException
[java.lang.UnsatisfiedLinkError] push
So, I think, I should better to make original parser program.
Before all of that work, maybe you could try one thing to solve
this exception. Did you add the Foundation framework to your
project?
Oh! good point!
I tried to add Foundation.framework in my WOApp.
BUT occurred same exception.
and one more, add some class files to MacOSClassPath.txt, like below.
WOROOT/Library/Java/com/apple/cocoa/foundation/
NSPropertyListSerialization.class
WOROOT/Library/Java/com/apple/cocoa/foundation/NSAutoreleasePool.class
WOROOT/Library/Java/com/apple/cocoa/foundation/NSMutableArray.class
but, ocurred same exception..
here is console log.
Loading
/Users/kzkamiya/Roots/TestNSPropertyListSerialization.woa/Contents/
MacOS/MacOSClassPath.txt
Generated classpath:
/Users/kzkamiya/Roots/TestNSPropertyListSerialization.woa/Contents/
Resources/Java/testnspropertylistserialization.jar
/System/Library/Frameworks/JavaFoundation.framework/Resources/Java/
javafoundation.jar
.......
/System/Library/Frameworks/Foundation.framework/
/System/Library/Frameworks/Cocoa.framework/
.......
/System/Library/Java/com/apple/cocoa/foundation/
NSPropertyListSerialization.class
/System/Library/Java/com/apple/cocoa/foundation/>
NSAutoreleasePool.class
/System/Library/Java/com/apple/cocoa/foundation/NSMutableArray.class
.......
Thanks,
Kazutaka.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.