特定のアーティストの音楽アプリケーションがあり、ユーザーが各アルバムを単独で購入できるさまざまなアルバムが含まれており、特定のアルバムを購入すると、そのボタンが購入から再生に変わり、このアルバムの曲がアプリにリストされますが、更新されたバージョンを実行したところ、ユーザーがアプリケーションを更新すると、デフォルトのようにリセットされ、再生ボタンが購入ボタンに置き換えられ、ユーザーは最初に購入したアルバムを再ダウンロードする必要があることがわかりましたバージョン、すべてのバージョンですべてのコンテンツを利用できるようにするにはどうすればよいですか?
それが、テーブルビューでボタンの画像が「購入」から「再生」に変わる方法です3
NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *myPath = [myPathList objectAtIndex:0];
NSString* storagePath = [myPath stringByAppendingPathComponent:@"purchasedAlbums.plist"];
NSArray* valueList = [[NSArray alloc] initWithContentsOfFile:storagePath];
UIImage *change1 = [UIImage imageNamed:@"playalbum-06.png"];
UIImage *change2 = [UIImage imageNamed:@"playalbum-07.png"];
UIImage *change3 = [UIImage imageNamed:@"playalbum-08.png"];
UIImage *change4 = [UIImage imageNamed:@"playalbum-09.png"];
UIImage *change5 = [UIImage imageNamed:@"playalbum-11.png"];
UIImage *change6 = [UIImage imageNamed:@"playalbum-12.png"];
UIImage *change7 = [UIImage imageNamed:@"playalbum-10.png"];
UIImage *change8 = [UIImage imageNamed:@"playalbum-13.png"];
UIImage *change9 = [UIImage imageNamed:@"ipadplay-16.png"];
UIImage *change10 = [UIImage imageNamed:@"ipadplay-17.png"];
UIImage *change11 = [UIImage imageNamed:@"ipadplay-18.png"];
UIImage *change12 = [UIImage imageNamed:@"ipadplay-19.png"];
UIImage *change13 = [UIImage imageNamed:@"ipadplay-20.png"];
UIImage *change14 = [UIImage imageNamed:@"ipadplay-21.png"];
int i;
for (i = 0; i < [AlbumsImages count]; i++) {
if ([[valueList objectAtIndex:i+1] intValue]) {
if (i == 0) {
[AlbumsImages replaceObjectAtIndex:0 withObject:change1];
}
if (i == 1) {
[AlbumsImages replaceObjectAtIndex:1 withObject:change2];
}
if (i == 2) {
[AlbumsImages replaceObjectAtIndex:2 withObject:change3];
}
if (i == 3) {
[AlbumsImages replaceObjectAtIndex:3 withObject:change4];
}
if (i == 4) {
[AlbumsImages replaceObjectAtIndex:4 withObject:change5];
}
if (i == 5) {
[AlbumsImages replaceObjectAtIndex:5 withObject:change6];
}
if (i == 6) {
[AlbumsImages replaceObjectAtIndex:6 withObject:change7];
}
if (i == 7) {
[AlbumsImages replaceObjectAtIndex:7 withObject:change8];
}
if (i == 8) {
[AlbumsImages replaceObjectAtIndex:8 withObject:change9];
}
if (i == 9) {
[AlbumsImages replaceObjectAtIndex:9 withObject:change10];
}
if (i == 10) {
[AlbumsImages replaceObjectAtIndex:10 withObject:change11];
}
if (i == 11) {
[AlbumsImages replaceObjectAtIndex:11 withObject:change12];
}
if (i == 12) {
[AlbumsImages replaceObjectAtIndex:12 withObject:change13];
}
if (i == 13) {
[AlbumsImages replaceObjectAtIndex:13 withObject:change14];
}
そして、ダウンロード時にアルバムが保存された場所
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:URL]];
[request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"]
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp3",[self FileNameGetter:Albumid FileID:CurrentSongID ]]]];
そして、それはアプリケーションがロードされたときに起こることです
NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *myPath = [myPathList objectAtIndex:0];
NSString* storagePath = [myPath stringByAppendingPathComponent:@"purchasedAlbums.plist"];
NSArray* valueList = [[NSArray alloc] initWithContentsOfFile:storagePath];
if ([valueList count]==0) {
valueList = [NSArray arrayWithObjects: @"0" ,@"0" ,@"0" , @"0" ,@"0" ,@"0" , @"0" ,@"0" ,@"0" , @"0" ,@"0" ,@"0" , @"0" ,@"0" ,@"0" , nil];
[valueList writeToFile:storagePath atomically:true];
}
valueList=nil;
myPathList=nil;
myPath =nil;
storagePath =nil;
[valueList release];
[myPathList release];
[myPath release];
[storagePath release];
私は本当に助けに感謝します:)