4

基本的に、Javaコードをobjective-cに変換して、iPhone用のViewControllerで使用できるようにする必要があります。

XML-RPCPHPコード

$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));      

PHPXML-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 に答える