1016-01-首頁16-計算配圖的frame----MJExtention的使用,mjextention

來源:互聯網
上載者:User

1016-01-首頁16-計算配圖的frame----MJExtention的使用,mjextention

 

 

-------HWPhoto.h---------------------------------------------

#import <Foundation/Foundation.h>

@interface HWPhoto : NSObject
/** 縮圖地址 (模型屬性)。   thumbnail_pic  是  pic_urls 數組裡面的字典 裡面的 key */
@property (nonatomic, copy) NSString *thumbnail_pic;  //  要保證 字典屬性 和 模型屬性 一樣。(字典屬性即為pic_urls 數組裡面的字典的key)     


@end

-------HWPhoto.m---------------------------------------------

#import "HWPhoto.h"
@implementation HWPhoto
@end

 

-------HWStatus.h---------------------------------------------

#import <Foundation/Foundation.h>
@class HWUser;

@interface HWStatus : NSObject
/**    string    字串型的微博ID*/
@property (nonatomic, copy) NSString *idstr;

/**    string    微博資訊內容*/
@property (nonatomic, copy) NSString *text;

/**    object    微博作者的使用者資訊欄位 詳細*/
@property (nonatomic, strong) HWUser *user;

/**    string    微博建立時間*/
@property (nonatomic, copy) NSString *created_at;

/**    string    微博來源*/
@property (nonatomic, copy) NSString *source;

/** 微博配圖地址。多圖時返回多圖連結。無配圖返回“[]” */
@property (nonatomic, strong) NSArray *pic_urls;

 

/** 被轉寄的原微博資訊欄位,當該微博為轉寄微博時返回 */
@property (nonatomic, strong) HWStatus *retweeted_status; // 這個卻不要像 pic_urls 那樣子:

- (NSDictionary *)objectClassInArray
{  //  在返回的資料裡面有一個 pic_urls 數組,裡面存放的是多個字典,每一個字典表示一個圖片的url。下行寫法會把 pic_urls 字典數組 轉為 模型數組。也就是把pic_urls數組裡面的每一個字典 分別 轉換為 HWPhoto 模型。
    return @{@"pic_urls" : [HWPhoto class]};
}

因為在用 MJExtension 轉換的時候,retweeted_status 是可以直接轉換成模型的,因為知道它的類型就是 HWStatus;而數組裡面是什麼卻不知道,所以需要類似 return @{@"pic_urls" : [HWPhoto class]}; 指定。


@end

 

-------HWStatus.m---------------------------------------------

#import "HWStatus.h"
#import "MJExtension.h"
#import "HWPhoto.h"

@implementation HWStatus
- (NSDictionary *)objectClassInArray
{

  //  在返回的資料裡面有一個 pic_urls 數組,裡面存放的是多個字典,每一個字典表示一個圖片的url。下行寫法會把 pic_urls 字典數組 轉為 模型數組。也就是把pic_urls數組裡面的每一個字典 分別 轉換為 HWPhoto 模型。
    return @{@"pic_urls" : [HWPhoto class]};
}
@end

______________________________________________________________________________________________

                                                     1

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.