Search code examples
iosnsmutablestringairprint

AirPrint and a NSMutableString


I am a little stuck:-)

I have a small app which allows me to put in fields from the address book into a label type UIView. Now I wish to be able to print those labels out:-) I do not mind at this stage if it goes onto a normal piece of paper - I will sort that part out later.

My Questions is - I cannot figure out how to print text that I draw out from the addressbook.

EXAMPLE:

First Name: -------- | This become | First Name: Joe Bloggs (from the address book)

enter image description here

Now the section that has the name, household, age and number - That is the section I want to print out.

Any Help?? Please???

PS I have start to code my way through this, so I am not giving this to you blank. I just got a fair bit of code:-) So I am not sure which bit to post.

The bit that causes the error is this:

NSMutableString *printBody = [NSMutableString stringWithFormat:@"%@, %@",self.encoded.text, self.decoded.text];

Cheers --Jeff


Solution

  • Your error : property 'encoded' not found on object of type 'printViewController *' seems to indicate that you have not declared encoded as a property. In order to use the dot notation you are using you will have to declare encoded and decoded as properties.

    I'm going to assume that encoded is of class UILabel, since that is what it looks like in your screenshot. If my assumption about it's class is correct you need to declare it as a property like so.

    In your printViewController.h file you should have:

    @property (assign, nonatomic) IBOutlet UILabel *encoded;
    

    And in your .m file you should have:

    @synthesize encoded;
    

    Or some manually written accessors.

    You will need to connect the label itself to your IBOutlet on the view controller which you can do from interface builder.

    If I have misunderstood your layout leave a comment.