English 中文(简体)
TTURLCache to cache my pornography and data
原标题:TTURLCache to cache my image and data

我用了320张照相片,确实运转良好,看上去看病。 基本上,我不需要担心所有从serv头到serv的光头.,因为320部电离板,管理并重新安排了我的数据,所有这一切都是在幕后进行的。

当我开始注意到在320年实施的这一称为TTURLCache的魔法切割机制。 在标题档案中,我发现以下接口方法:

/**
 * Stores a data on disk.
 */
- (void)storeData:(NSData*)data forURL:(NSString*)URL; //method 1
- (void)storeData:(NSData*)data forKey:(NSString*)key;

/**
 * Stores an image in the memory cache.
 */
- (void)storeImage:(UIImage*)image forURL:(NSString*)URL; //method 2

/**
 * Stores an etag value in the etag cache.
 */
- (void)storeEtag:(NSString*)etag forKey:(NSString*)key; //method 3

我的问题:

  1. Method 1 and method 2 in the above code: are they only capable of storing data, or are they capable of both fetching and storing?
  2. What is an etag in method 3?
  3. Method 1 says it will store the data on disk, while method 2 says it will store the image in memory. If I use method 2 to store an image, will it get lost once I kill and restart my app?

预示着很多事。

最佳回答
  1. Those are the storage methods. The retrieval methods are separate. (See below.)
  2. Etags are a way to optimize network traffic. See Wikipedia for a good intro.
  3. I think that Three20 both stores the image file on disk, and the decoded image itself in memory. Certainly, any in-memory caches would be cleared if the app re-started, but remember that under iOS 4, that probably happens less often that you think.

a. 从海滩获取数据,尝试:

/**
 * Gets the data for a URL from the cache if it exists and is newer than a minimum timestamp.
 *
 * @return nil if hthe URL is not cached or if the cache entry is older than the minimum.
 */
- (NSData*)dataForURL:(NSString*)URL expires:(NSTimeInterval)expirationAge
           timestamp:(NSDate**)timestamp;
- (NSData*)dataForKey:(NSString*)key expires:(NSTimeInterval)expirationAge
           timestamp:(NSDate**)timestamp;

/**
 * Gets an image from the in-memory image cache.
 *
 * @return nil if the URL is not cached.
 */
- (id)imageForURL:(NSString*)URL;
- (id)imageForURL:(NSString*)URL fromDisk:(BOOL)fromDisk;

不过,我建议通过来文方阅读。 如果记忆发挥作用,TTURLCache就等于一等。

问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签