4

基本上需要将java代码翻译成objective-c,以便为iphone的View Controller做好准备。

XML-RPC PHP 代码

$structArray[] = new xmlrpcval(array(
            'graffer'  => new xmlrpcval($graffer),
            'thumb'    => new xmlrpcval($thumb),
            'titletag' => new xmlrpcval($titletag),                         
            'content'  => new xmlrpcval($content),
            'created'  => new xmlrpcval($date_time),
            'params'   => new xmlrpcval($params),
            'cid'      => new xmlrpcval($cid),
            'id'      => new xmlrpcval($id)
        ), 'struct');                   
    }   
return new xmlrpcresp(new xmlrpcval($structArray , $xmlrpcArray));      

PHP XML-RPC 响应

回复:

<methodResponse>
<params>
<param>
<value><array>
<data>
<value><struct>
<member><name>graffer</name>
<value><string>axl jordan</string></value>
</member>
<member><name>thumb</name>
<value><string></string></value>
</member>
<member><name>titletag</name>
<value><string>axl jordan New Graffer1 Member</string></value>
</member>
<member><name>content</name>
<value><string></string></value>
</member>
<member><name>created</name>
<value><string>WEEK AGO</string></value>
</member>
<member><name>params</name>
<value><string>default.jpg</string></value>
</member>
<member><name>cid</name>
<value><string>292</string></value>
</member>
<member><name>id</name>
<value><string>1985</string></value>
</member>
</struct></value>
<value><struct>
<member><name>graffer</name>
<value><string>Core</string></value>
</member>
<member><name>thumb</name>
<value><string></string></value>
</member>
<member><name>titletag</name>
<value><string>Core New Graffer1 Member</string></value>
</member>
<member><name>content</name>
<value><string></string></value>
</member>
<member><name>created</name>
<value><string>WEEK AGO</string></value>
</member>
<member><name>params</name>
<value><string>default.jpg</string></value>
</member>
<member><name>cid</name>
<value><string>291</string></value>
</member>
<member><name>id</name>
<value><string>1984</string></value>
</member>
</struct></value>
<value><struct>
<member><name>graffer</name>
<value><string>amputate</string></value>
</member>
<member><name>thumb</name>
<value><string></string></value>
</member>
<member><name>titletag</name>
<value><string>amputate New Graffer1 Member</string></value>
</member>
<member><name>content</name>
<value><string></string></value>
</member>
<member><name>created</name>
<value><string>WEEKS AGO</string></value>
</member>
<member><name>params</name>
<value><string>default.jpg</string></value>
</member>
<member><name>cid</name>
<value><string>290</string></value>
</member>
<member><name>id</name>
<value><string>1983</string></value>
</member>
</struct></value>
</data>
</array></value>
</param>
</params>
</methodResponse>


Java Android HashMap

private void MyG1Activity(Object[] results) {       
    myG1Acts = new ArrayList<HashMap<String,Object>>();
    Globals myGlobal = (Globals)getApplicationContext();        
    String TimageUrl = myGlobal.imageUrl;
    HashMap<String,Object>hm = null;
    for (Object o : results){           
        HashMap <?,?> map = (HashMap<?,?>)o;
        hm = new HashMap<String,Object>();
        Object graffer1 = map.get(GRAFFER);
        if(graffer1 != null){
            lGraffer1 = graffer1.toString();
            hm.put(GRAFFER, lGraffer1);
        }
        Object tthumbnail = map.get(THUMB);
        if(tthumbnail != null){   
            lThumbnail = TimageUrl + tthumbnail.toString();
            bitmap = ImageManager.displayImage(lThumbnail);             
            hm.put(THUMB, bitmap);
        }   
        Object ttag = map.get(TITLETAG);
        if( ttag != null ){
            ltag = ttag.toString();
            hm.put(TITLETAG, ltag); 
        }
        Object tcontent = map.get(CONTENT);
            if( tcontent != null ){
                hm.put(CONTENT, tcontent);
            }
        Object tCreated = map.get(CREATED);
            if( tCreated != null ){
                hm.put(CREATED, tCreated);
            }
        Object tParams = map.get(PARAMS);
            if( tParams != null){
                if (tParams.toString() == DEFAULT_THUMBNAIL){
                    lThumbnail = TimageUrl + tParams.toString();
                }else{
                    jParams = TimageUrl + tParams.toString();
                    jParams = jParams.replace("Vs ", "\"/><img src=\"" + TimageUrl );
                    hm.put(IMAGE, jParams);  
                }
            }
        Object tcid = map.get(CID);
            if( tcid != null ){
                hm.put(CID, tcid);
            }
        Object tid = map.get(ID);
            if( tid != null ){
                hm.put(ID, tid);
                getMoreID =  Integer.valueOf(tid.toString());
            }   
            myG1Acts.add(hm);
    }   

}

xcode中控制台的输出

{
cid = 292;
created = "WEEK AGO";
graffer = "axl jordan";
id = 1985;
params = "default.jpg";
titletag = "axl jordan New Graffer1 Member";}
int k = 1;
for (NSDictionary *key in finalData) {
    NSString *cid = [key objectForKey:@"cid"];        
    NSLog(@"key %d is %@",k++ ,cid);
    NSString *titleTag = [key objectForKey:@"titletag"];
    NSLog(@"key %d is %@",k++ ,titleTag);
}

找到了我自己的答案

NSDictionary *key = [returnedPost objectAtIndex:indexPath.row];
NSString *titleTag = [key objectForKey:@"titletag"];

4

1 回答 1

0

xcode中控制台的输出

{
cid = 292;
created = "WEEK AGO";
graffer = "axl jordan";
id = 1985;
params = "default.jpg";
titletag = "axl jordan New Graffer1 Member";}
int k = 1;
for (NSDictionary *key in finalData) {
    NSString *cid = [key objectForKey:@"cid"];        
    NSLog(@"key %d is %@",k++ ,cid);
    NSString *titleTag = [key objectForKey:@"titletag"];
    NSLog(@"key %d is %@",k++ ,titleTag);
}

找到了我自己的答案

NSDictionary *key = [returnedPost objectAtIndex:indexPath.row];
NSString *titleTag = [key objectForKey:@"titletag"];

于 2014-01-31T17:44:47.240 回答