i'm new on ios development , i'm working on pdf application , need store pdf file on nsdata variable, have pdf path message error when try put pdf on nsdata variable using datawithcontentsoffile simple code :
nserror *error; nsstring *pdfpath = [nsstring stringwithformat:(@"%@"),document.fileurl ]; nsstring *newpath = [pdfpath stringbyreplacingoccurrencesofstring:@"file://localhost" withstring:@""]; nslog(@"originalpdfpath => %@", newpath); nsdata *pdfdata = [nsdata datawithcontentsoffile:newpath options:nsdatareadinguncached error:&error];
nb : pdf path in format : /users/bluesettle/library/application%20support/iphone%20simulator/6.0/applications/bbef320e-7e2a-49da-9fcf-9cfb01cc0402/contractapp.app/pro.ios.table.views.pdf
thanks
cocoa error 260 nsfilereadnosuchfileerror
(as listed in foundationerrors.h
), meaning file not found @ path specified.
the problem path still contains encoded spaces (%20
), because you're basing on url. can this:
nsdata *pdfdata = [nsdata datawithcontentsoffile:[document.fileurl path]];
Comments
Post a Comment