If the folder ~/Library/Mobile Documents does not exits
mkdir ~/Library/Mobile\ Documents
If the folder ~/Library/Mobile Documents exits
cd ~/Desktop
ln -s ~/Library/Mobile\ Documents iCloud_Documents
Now all files in the folder iCloud_Documents on the desktop are stored in Apple's iCloud and synchronized with your iOS devices and Macs.
Synchronous downloads allow to request data from the internet, wait until that data is received, and then move on to the next step in your application.
I will describe the process with some attached code. The code is both synchronous and blocking so the method will not return before the data is received.
- (SimpleKML *) getData: (NSURL *) url
{
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSURLResponse *response;
NSError *error;
success = NO;
SimpleKML* kmlData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
//if there is no kmlData the download failed
if (!kmlData)
{
[self log:@"Download error: %@", [error localizedFailureReason]];
return;
}
if ((response.expectedContentLength == NSURLResponseUnknownLength) ||
(response.expectedContentLength < 0))
{
[self log:@"Download error."];
return;
}
if (![response.suggestedFilename isEqualToString:url.path.lastPathComponent])
{
[self log:@"Name mismatch. Probably carrier error page"];
return;
}
if (response.expectedContentLength != result.length)
{
[self log:@"Got %d bytes, expected %d", result.length, response.expectedContentLength];
return;
}
success = YES;
[self log:@"Read %d bytes", result.length];
[result writeToFile:DEST_PATH atomically:YES];
[self log:@"Data written to file: %@.", DEST_PATH];
[self log:@"Response suggested file name: %@", response.suggestedFilename];
[self log:@"Elapsed time: %0.2f seconds.", [[NSDate date] timeIntervalSinceDate:startDate]];
return kmlData;
}
This call blocks until the request fails (returning nil and an error is produced) or the data finishes downloading. The several if clauses check if the response data contain any misleading or unwanted data which my come from downloading from the wrong website.
For using the simpleKML Library you need to download the framework from this github project.
https://github.com/incanus/Simple-KML/
This problem was solved by the creation of iTunes-Affiliate-Links, that lead the listener automatically to the iTunes Store.
Firstly, the user has to join the iTunes-Affiliate Program of Apple (http://www.apple.com/itunes/affiliates). After the registration, you will get the "Partner-ID" and the link to the "iTunes Link Maker"-Web page, where you can generate the specific links (see "Screenshot iTunes Link Maker").
Afterwards, the user can click on the Album, Artist or Song Link and a pop-up opens with the details. The customer can choose between a small and a big button or text only (see "Screenshot Linking"). Finally, the programmer has to insert the resulting HTML-Code into the website.
When a user clicks on the link, iTunes will open and navigate to the correct page. If the user doesn't have iTunes, the link will automatically take the user to an iTunes download page.