Three20 NetWork
16612 단어 NetWork
1. 우선 우리 먼저 보 자 TTURLRequest 같은 종 류 는 http method, body 를 사용자 정의 할 수 있 습 니 다. parameters, as well as natural response. processing using TTURLResponse objects.
#import <Foundation/Foundation.h>
// Network
#import "Three20Network/TTURLRequestCachePolicy.h"
// Core
#import "Three20Core/TTCorePreprocessorMacros.h"// For __TTDEPRECATED_METHOD
@protocol TTURLRequestDelegate;
@protocol TTURLResponse;
@interface TTURLRequest : NSObject {
NSString* _urlPath; //url
NSString* _httpMethod; //http
NSData* _httpBody; //http
NSMutableDictionary* _parameters; //
NSMutableDictionary* _headers; //http
NSString* _contentType; //
NSStringEncoding _charsetForMultipart; //
NSMutableArray* _files; //
id<TTURLResponse> _response;
TTURLRequestCachePolicy _cachePolicy; //
NSTimeInterval _cacheExpirationAge; // , 1
NSString* _cacheKey; // key
NSDate* _timestamp;
NSInteger _totalBytesLoaded; //
NSInteger _totalBytesExpected; //
NSInteger _totalBytesDownloaded; //
NSInteger _totalContentLength; //
id _userInfo; //
BOOL _isLoading; //
BOOL _shouldHandleCookies; // cooke
BOOL _respondedFromCache; //
BOOL _filterPasswordLogging; //
NSMutableArray* _delegates;
}
/**
* url
*/
@property (nonatomic, copy) NSString* urlPath;
/**
, , urlPath
*/
@property (nonatomic, copy) NSString* URL__TTDEPRECATED_METHOD;
/**
* http
* @example @"POST"
* @example @"GET"
* @example @"PUT"
* @ (t @"GET")
*/
@property (nonatomic, copy) NSString* httpMethod;
/* * response data , , TTURLXMLResponse extThree20XML
* @see TTURLDataResponse
* @see TTURLImageResponse
* @see TTURLXMLResponse
*/
@property (nonatomic, retain) id<TTURLResponse> response;
/**
* Http body
* , . POST put , 。
* httpBody , post put data parameters ,
*/
@property (nonatomic, retain) NSData* httpBody;
/**
* The content type of the data in the request.
* , httpMethod post put , contentType @"multipart/form-data".
*/
@property (nonatomic, copy) NSString* contentType;
/**
* HTTP POST/PUT
*/
@property (nonatomic, readonly) NSMutableDictionary* parameters;
/**
* HTTP headers.
*/
@property (nonatomic, readonly) NSMutableDictionary* headers;
/**
* @ : TTURLRequestCachePolicyDefault
*/
@property (nonatomic)TTURLRequestCachePolicy cachePolicy;
/**
* response
* TT_DEFAULT_CACHE_EXPIRATION_AGE (1 week)
*/
@property (nonatomic)NSTimeInterval cacheExpirationAge;
/**
* cache key, key request data 。
* post put, post put cache key 。
* cache key , cache key, 。
*/
@property (nonatomic, copy) NSString* cacheKey;
/**
* ,
* TTUserInfo
* @see TTUserInfo
*/
@property (nonatomic, retain) id userInfo;
@property (nonatomic, retain) NSDate* timestamp;
/**
*
*/
@property (nonatomic) BOOL isLoading;
/**
* cookie
* @param YES if cookies should be sent with and set for this request;
* otherwise NO.
* @discussion The default is YES - cookies are sent from and
* stored to the cookie manager by default.
* @default YES
*/
@property (nonatomic)BOOL shouldHandleCookies;
/**
*
*/
@property (nonatomic)NSInteger totalBytesLoaded;
/**
*
*/
@property (nonatomic)NSInteger totalBytesExpected;
/**
*
*/
@property (nonatomic)NSInteger totalBytesDownloaded;
/**
*
*/
@property (nonatomic)NSInteger totalContentLength;
/**
*
*
*/
@property (nonatomic)BOOL respondedFromCache;
/**
.
*/
@property (nonatomic,assign) BOOL filterPasswordLogging;
/**
* multipart/form-data *
* @ NSUTF8StringEncoding
*/
@property (nonatomic)NSStringEncoding charsetForMultipart;
/**
* An array of non-retained objects that receive messages about the progress of the request.
*/
@property (nonatomic, readonly) NSMutableArray* delegates;
+ (TTURLRequest*)request;
+ (TTURLRequest*)requestWithURL:(NSString*)URL delegate:(id/*<TTURLRequestDelegate>*/)delegate;
- (id)initWithURL:(NSString*)URL delegate:(id/*<TTURLRequestDelegate>*/)delegate;
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
/**
* ,
*/
- (void)addFile:(NSData*)data mimeType:(NSString*)mimeType fileName:(NSString*)fileName;
/**
*
* ,
* 。
* @return YES ,
*/
- (BOOL)send;
/**
*
* ,
*/
- (BOOL)sendSynchronously;
/**
*
* url ,
*/
- (void)cancel;
- (NSURLRequest*)createNSURLRequest;
@end
TTURLRequest 대상 만 들 기
TTURLRequest *request = [TTURLRequestrequestWithURL:kRequestURLPath delegate:self];
TTURLRequestDelegate 프로 토 콜 실현
그림 처리 요청 사용: TTURLImage Response, TTURLImage Response 는 response types 중의 하나 일 뿐 사용 할 수 있 습 니 다. TTURLDataResponse 와 TTURLXMLResponse (이 xmlResponse 는 확장 프레임 워 크 를 추가 해 야 합 니 다 extThree20XML )
request.response = [[[TTURLImageResponsealloc] init]autorelease];
[request send]; //
#pragma mark -
#pragma mark TTURLRequestDelegate
//
- (void)requestDidStartLoad:(TTURLRequest*)request {
[_requestButtonsetTitle:@"Loading..."forState:UIControlStateNormal];
}
//
- (void)requestDidFinishLoad:(TTURLRequest*)request {
TTURLImageResponse* imageResponse = (TTURLImageResponse*)request.response;
if (nil == _imageView) {
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
[_scrollView addSubview:_imageView];
}
_imageView.image = imageResponse.image;
[_imageView sizeToFit];
_imageView.alpha = 0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
_requestButton.alpha = 0;
_clearCacheButton.alpha = 0;
[_scrollView setContentSize:_imageView.frame.size];
_imageView.alpha = 1;
[UIView commitAnimations];
}
//
- (void)request:(TTURLRequest*)request didFailLoadWithError:(NSError*)error {
[_requestButtonsetTitle:@"Failed to load, try again."forState:UIControlStateNormal];
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
제5장 iSNSP 메시지 형식(iSNSP Message Format) - 6, 등록 및 조회 메시지PDU Payload의 모든 Source, Message Key, Delimiter, Operating Attribute는 Tag-Length-Value(TLV) 형식으로 저장됩니다.iSNS 등록 및 조회 메시지는 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.