What is the best way to pass a string containing a pdf name in Objective-C?
(I am a newbie on Objective-C, and) I have been trying to pass a pdf name and initialize a class like this:
contCon = [[contentController alloc] initwithPdf:@"mag.pdf"];
and
-(id)initwithPdf:(NSString *)pdfName{ ... }
it gave me no error but pdf name doesn't come up as 开发者_如何学JAVAI sent it. So i tried to do this:
contCon = [[contentController alloc] initwithPdf:CFSTR("mag.pdf")];
I also couldn't figure ou how to get this type of data in the method.
-(id)initwithPdf:(CFSTR)pdfName
or
-(id)initwithPdf:(CFSTR *)pdfName
doesn't seem to work, and google didn't help me either.
I want to know in what type to pass the name of the pdf file. Thanks in advance.
contCon = [[contentController alloc] initwithPdf:@"mag.pdf"];
and
-(id)initwithPdf:(NSString *)pdfName{ ... }
is better one......
Your first method is the right one. And what does "it doesn't come up" mean?
Why don't you pass the whole filepath of the pdf,rather than just the pdfName??
Define : "pdf name doesn't come up as I sent it"
精彩评论