Analysis finds private API usage although I've changed that code - ios

My app was rejected after App Store review for using the private method -[UIImage initWithData:cache:], but this is my code :
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[details image]]];
picture = [[UIImage alloc] initWithData:imageData];
An earlier version of the app I submitted did contain an initWithData:cache: call, but I removed this before resubmitting. Is it possible I need to clean the build? Is the build somehow "remembering" the old code?

All the functions you used in that snippet have public documentation, so it would be worth complaining to Apple and demanding clarification. Here are the links to the documentation for each of those, BTW:
NSURL URLWithString
NSData dataWithContentsOfURL
UIImage initWithData
Note that Apple's message refers to the "initWithData:cache:", however, the snippet you provided refers to "initWithData:". Are you sure that the code you've provided is what was referred to by Apple?

(Copied out from an edit to the question by the OP.)
I resolved this by creating a completely new project and copying files across from old project. It looks like something was ghosting from when the project did contain the initWithData:cache: method.

Related

getting csv to download in iOS

I'm aware that there are similar questions posted, but this is a very specific issue that may or may not be related to code, it might be due to where I'm sourcing the file, and I need some advice.
I have an iPad app and am detecting whether there is an internet connection. If there is, then a .csv file is downloaded, saved, then split into an array. If not then a file held in the main bundle is used.
When using the file held in the main bundle, I can extract the data. The problem I have is when I try to download the .csv. The file is held on Document Manager, a Content Management System that is the only secure area for the file to be held for the company I work for and is therefore unavoidable. If I use this code:
NSString *urlString = #".../view-document.cgi?f=fundsspreadsheetc.csv";
(sorry, I need to keep the full link confidential)
NSURL *csvURL = [NSURL URLWithString:[urlString stringByAddingPercentageEscapesUsingEncoding:NSASCIIStringEncoding]];
NSData *urlData = [NSData dataWithContentsOfURL:csvURL options:NSDataReadingMappedAlways error:nil];
then urlData returns nil.
The original url opens the file on a windows laptop, but with a file name of view-document.cgi. I don't know if this is relevant.
If I change the url to:
"
http://download.finance.yahoo.com/d/quotes.csv?s=^GSPC+^IXIC+^dji+^GSPC+^BVSP+^GSPTSE+^FTSE+^GDAXI+^FCHI+^STOXX50E+^AEX+^IBEX+^SSMI+^N225+^AXJO+^HSI+^NSEI&f=sl1d1t1c1ohgv&e=.csv"
from a question set by shebi, then my code works.
What do I need to do to get my file to download?
much appreciated
Thanks for the help, it was problem with the link.

Creating CPTImages from images in xcassets file

So according to this, you have to use imageNamed for loading images now in iOS.
Unfortunately, CPTImage's constructors requires paths for loading images
So something like this:
[CPTImage imageForPNGFile:[[NSBundle mainBundle] pathForResource:#"plotsymbol" ofType:#"png"]]
These -pathForResource calls now fail because of asset catalogs.
So.. has anyone been able to do this? Did I miss something?
The CPTImage class will include an imageNamed method in a future release. It is available now on the release 2.0 branch. People are using the 2.0 code now but it is unfinished and subject to change in many areas before the final release.

Get list of files from URL iOS

Im working on an app that now has to go to a URL online and read all filenames inside a folder and get them into the app for parsing. How do I achieve this in iOS? Ive looked at NSURLConnection and didn't find anything.
What didn't you find with NSURLConnection that you were looking for?
That would be one standard way of downloding a file using HTTP.
You could do this, but it is synchronous.
NSData *urlData = [NSData dataWithContentsOfURL:url];
The only way to do this turns out to be a server side script!

How to print an image in iOS 4.2?

I find the Apple documentation difficult to read through. Perhaps someone out there is willing to share some code on how to easily print a JPG or PNG file in iOS 4.2?
There are three basic steps:
Instantiate an NSData object from your file.
Create a UIPrintInfo object that contains the job specs.
Send the data to a UIPrintInteractionController, which will begin the process.
See this article for a code sample.

Check if NSURL is Local File

This is a pretty simple question- how can I check if a NSURL is linking to a local file?
I know, RTFM, but I checked the documentation and I don't seem to see any methods related to this.
The only methods I did find were -isFileReferenceURL and -isFileURL, but I think these only check if the URL directly links to a file.
Note: I'm making an iPhone app, so by "local file" I mean a .html file stored in the project's resources.
Thanks for any help in advance.
The -isFileURL will check if your URL uses the file: scheme. It doesn't check whether it's referencing an actual file.
There is -isFileReferenceURL as of iOS 5 that checks if the url is an file reference. Before 5.0, it did nothing according to the documentation..
Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)
I hope this helps the new-comers...

Resources