Posts Tagged ‘ iOS ’


So I’ve been learning MapKit this week.

It’s been a fun new framework to look into.

Create an Annotation so you can have custom properties.

@interface Annotation : NSObject<MKAnnotation>

Add a category to it so you have a way of telling what it is.

This could be an enum.

In the Delegate method

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation

You can use the category to set up some properties like a button and the pin colour.

I’m wondering if the “reuseIdentifier” should be unique here too?

You’ve added a button, now how to call it?

You could add a target and action

[rightButton addTarget:## action:## forControlEvents:UIControlEventTouchUpInside];

but instead you can use the “calloutAccessoryControlTapped” delegate method.

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control

As this isn’t a  “MKAnnotation” like “viewForAnnotation” but an “MKAnnotationView” we need to get the annotation from the passed view.

if ([view.annotation isKindOfClass:[OotAnnotation class]]) { ... }

Then call pfs,

Then in the “prepareForSegue” you need to get the Annotation when you click on a Pin button, this can be cast from the Sender

if ([view.annotation isKindOfClass:[OotAnnotation class]]) { ... }
Annotation *annotation = (Annotation *)[(MKAnnotationView *)sender annotation];

You could then pass your custom Location details via the ViewController. (See code)

Searching for locations to add to the map:


Adding a route, need to investigate this more.


All Code


Pollen Today Widget

I want a today Widget to show pollen count.

I downloaded:

Clarityn’s Pollen Forecast UK by Bayer HealthCare AG

They have a website

It doesn’t have the Widget I wanted so I started looking for an API.



Accept: application/json


Form URL-Encoded



"{\"Durham & Newcastle\":{\"1499515201\":{\"precipitation\":8,\"maxTemp\":21,\"minTemp\":16,\"pollenLevel\":\"H\",\"humidity\":83,\"windSpeed\":7,\"weatherCode\":7,\"uvIndex\":5,\"pollenType\":\"Grass\"},\"1499601600\":{\"precipitation\":18,\"maxTemp\":18,\"minTemp\":15,\"pollenLevel\":\"H\",\"humidity\":80,\"windSpeed\":18,\"weatherCode\":7,\"uvIndex\":4,\"pollenType\":\"Grass\"},\"1499688000\":{\"precipitation\":23,\"maxTemp\":18,\"minTemp\":14,\"pollenLevel\":\"M\",\"humidity\":69,\"windSpeed\":11,\"weatherCode\":3,\"uvIndex\":7,\"pollenType\":\"Grass\"}}}"

Images; : 

I found Benadryl has one.



{"status_code":"200 OK","date":"2017-07-02T07:13:47+00:00","forecast":[{"date":"2017-06-29T08:00:01+00:00","pollen_count":"Low"},{"date":"2017-06-30T08:00:01+00:00","pollen_count":"Low"},{"date":"2017-07-01T08:00:01+00:00","pollen_count":"High"},{"date":"2017-07-02T08:00:01+00:00","pollen_count":"High","temperature":"18","weather_code":"01","weather":"Sunny"},{"date":"2017-07-03T08:00:01+00:00","pollen_count":"High","temperature":"18","weather_code":"07","weather":"Medium-level cloud"},{"date":"2017-07-04T08:00:01+00:00","pollen_count":"Moderate","temperature":"14","weather_code":"12","weather":"Light rain"}]}

Images; :


App doesn’t exist.

I’ve started building my own

img_4314 img_4315-1 img_4317-1
The Widget needs a lot of work but the basis is there, I’ve built a framework that gets all the data. Now to finish the UI…

Multi Select TableView

Want to select more than one row in a TableView?

Adding A Settings Bundle

I’d like to add a Settings section to my app to show Licenses and other info.

Maybe put the Options section there too.

[gist 5830083ef0625204a016 /]

Run a perl script:

perl <>


Useful ways to get data out of FMDB.


NSUInteger count = [db intForQuery:@"SELECT COUNT(field) FROM table_name"];

Make sure to include the FMDatabaseAdditions.h header file to use intForQuery:


NSUInteger max = [db intForQuery:@"SELECT MAX(field) FROM table_name"];


NSUInteger min = [db intForQuery:@"SELECT MIN(field) FROM table_name"];


NSUInteger average = [db intForQuery:@"SELECT AVG(field) FROM table_name"];

Sum (Σ)

NSUInteger sum = [db intForQuery:@"SELECT SUM(field) FROM table_name"];


NSUInteger total = [db intForQuery:@"SELECT TOTAL(field) FROM table_name"];

Done button on NumPad

I’ve been researching adding a done button to a NumPad and keep getting the same error:

Can't find keyplane that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad; using 2705787216_PortraitChoco_iPhone-Simple-Pad_Default

And it seems to take a lot of code.

Another option would be to add a toolbar above the keyboard.

Not sure how well this will work with TPKeyboardAvoiding but let’s see, and it does!

Grouping Data in Sections

I’ve been looking round for some tutorials on how to group data in sections.

This is unbelievably easy in CoreData but how do you do it with your own data and models.

Previous articles I’d found I either couldn’t get to work or didn’t work as expected.

I’ve recently found this article: