Lessons learned from eaGeier #4

Sending a PDF File

Yet again the excellent documentation at Apple provides all you need to send an email. Start by initializing a mail-composer view controller, add a subject, a text and the file you want to attach as NSData. To allow the user to set the mail recipient just provide an empty array for the recipients. Set the delegate if you want to use the delegate functionality and finally present the mail view controller.

MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
[mail setSubject:@"A Subject"];
[mail setMessageBody:@"A text you want to send with the PDF file." isHTML:NO];
[mail addAttachmentData:[NSData dataWithContentsOfFile:thePathToYourPDFFile] 
               mimeType:@"text/pdf" 
               fileName:fileNameOfThePDFFile];
[mail setToRecipients:[NSArray array]];
[mail setMailComposeDelegate:self];
[self presentModalViewController:mail animated:YES];
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Lessons learned from eaGeier #3

Printing a PDF File

Printing works like before straightforward following the instructions of the documentation at Apple. Start by obtaining a printing controller and check if printing is available at all:

UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
if  (pic && [UIPrintInteractionController canPrintData:pdfDataWeWantToPrint] ) {
    // we should be able to print
}

Continue reading “Lessons learned from eaGeier #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Lessons learned from eaGeier #2

Creating a PDF File

The eaGeier allows to print its data or to export it via email as PDF file. For both it needs to create a PDF file first.

Creating a PDF file works straightforward following the instructions of the documentation at Apple. Start by opening a new file and start with a page:

UIGraphicsBeginPDFContextToFile(pdfFileName, CGRectZero, nil);
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);

Continue reading “Lessons learned from eaGeier #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Lessons learned from eaGeier #1

Display a Message when a Table is empty

When the eaGeier is opened the first time and there is no data available for display in the tables, it would be nice to display an appropriate message instead an empty table.

An idea was to adjust numberOfSectionsInTableView:, tableView:numberOfRowsInSection: and tableView:cellForRowAtIndexPath: accordingly. However as NSFetchedResultsController is used to populate the table with Core Data and it monitors the table closely the manipulation of the table outside its scope was not easily possible.

Instead I added an sub view on top of the table view displaying the empty-table message. To prevent showing it while data is still loading, I used a delayed animation to present the sub view.

eaGeier – empty table message
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Final Project: eaGeier

The eaGeier has been developed as final project for the Coding Together course.

It’s an tool for accounting on cash basis mainly used for small companies in Austria (Einnahmen-Ausgaben-Rechnung) and Germany (Einnahmenüberschussrechnung).

The app is a local port from the server application at www.ea-geier.at.

A demo of the app is available at YouTube.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Lecture #19: Automated Testing

Please note, this blog entry is from a previous course. You might want to check out the current one.

Lecture nineteen is named “19. Automated Testing (December 6, 2011) – HD” and can be found at iTunes.

The lecturer Andy Matuschak from the UIKit team at Apple uses a short demo to introduce unit tests and automation.

Unit tests are defined by creating subclasses of SenTestCase. The actual unit tests are methods starting with the prefix test, testing expectations using STAssert* and use the methods setUP and tearDown for shared initialization and clean up.

iOS UI Automation allows to run top down tests on the user interface using the automation tool of Instruments. Actions can be recorded and the app be manipulated via UIAElements in JavaScript, which can also be used to inspect states calling UIALogger logFail/Pass methods. Within a script accessibilityLabels can be used for easy access to interface elements.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

DocSets for iOS

Searching through the documentation in Xcode can be a quite tedious task, especially if you have multiple versions of documentations. DocSets for iOS allows to store the documentation on an iPhone or an iPad and amazes with its speed searching the documentation.

It is available for download for free at github (which needs to be installed manually), or directly at the App store (especially when you want to support the developer).

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail