Sunday, April 28, 2013

iOS Localize Image for Language of Applicaiton


How to localize images for iOS?
Put your images into localized folder, such as "en.lproj" , "zh.lproj"
This works for System Language.
But how about using language of application?

We can use string of app language by "NSLocalizedStringFromTable"
But there is NO such function for image.


Here is a solution.
Use the following code to get the path of the image of the app language.

NSString *path = [[NSBundle mainBundle] pathForResource:@"image_name" ofType:@"jpg" inDirectory:@"zh.lproj"]; 

or 

NSString *path = [[NSBundle mainBundle] pathForResource:@"image_name" ofType:@"jpg" inDirectory:@"" forLocalization:@"zh"];


UIImage *image = [UIImage imageWithContentsOfFile:path];

Thursday, April 25, 2013

Config Apache SVN server for Mountain Lion


After upgrade to Mac OS X 10.8 Mountain Lion.
My local SVN server is not working.
The setting should be the same, but the svn setting is removed from httpd.conf
How to get it work again?  Let's GO!!


Create file "/etc/apache2/other/svn.conf",
Add the following lines into the "svn.conf"

#svn module
LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so
LoadModule authz_svn_module libexec/apache2/mod_authz_svn.so

<Location /svn>
DAV svn
SVNPath "/svn"
AuthType Basic
AuthName "admin"
AuthUserFile /etc/your_user_name.htpasswd
Require valid-user
</Location>


sudzC SOAP web service namespace problem



I am using sudzC to generate objective-C codes to use SOAP webservice of a Java Tomcat server.
But is doesn't work. There must be some formatting problem.


<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://example.com/"><soap:Body>
<getMethod>
    <arg0>aaa</arg0>
    <arg1>8</arg1>
</getMethod>
</soap:Body></soap:Envelope>


return error message:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body>
<soap:Fault><faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: unexpected element (uri:"http://example.com/", local:"arg0"). Expected elements are &lt;{}arg0&gt;,&lt;{}arg1&gt; </faultstring></soap:Fault>
</soap:Body></soap:Envelope>

server is expecting <{}arg0>, <{}arg1>
{} means the namespace is empty.
arg0 and arg1 should have NO namespace.