Try the search, it's linked to some great forums

Tuesday, November 19, 2013

RaceTracker javascripts & notes

This post contains notes on building our 'Virtual Eye for the Sailing/Racing Guy' (VERG) race tracking program.  The system takes multiple KML/GPX/KMZ files and assembles them into a file to be displayed in 3-D on Google Earth.  The Google Earth screen can be embedded into your website.  The VERG screen has a playback control which allows the playback, forward, reverse and playback speed controls.  This control along with Google Earth's pan, tilt & zoom controls allows for great viewing and analysis of races.

The following html files are javaScripts modified from Google Earth's API home page at - https://developers.google.com/earth/ .    The examples page at -   http://code.google.com/apis/ajax/playground/?exp=earth#hello,_earth is where I got the following examples.

This javascript displays a specified area, viewpoint and standard Google Earth playback, and viewpoint controls - http://santacruznewspapertaxi.com/wp-content/uploads/2013/11/JavaScript010SailTracker.html

This javascript method gives you a view anywhere you want. createLookAt(lat, long, altitude, altitude mode, heading, tilt, range)    To find your viewPoint in Google Earth set your position & viewpoint and then goto - Google Earth - Edit - Get Info - View - Snapshot Current View.


Thursday, October 31, 2013

Great tutorial resources

App Submission process -  http://www.raywenderlich.com/8003/how-to-submit-your-app-to-apple-from-no-account-to-app-store-part-1

Wednesday, October 2, 2013

Project Punchlist

Tasks:  
  1. Make TLF about page the initial launch page for the app. Making this the initial page which will highlight TLF as an organization. 
  2. Flesh out the ThinkLocalFirst home page. The about page will be modified to look similar to Business detail pages. We can also add additional features if we want including, help page (describes app's features), YouTube video?, list button or whatever else is wanted. This home page should detail what TLF is all about.  
  3. Modify the TLF website database to include data required for the app. I will work with Gary Herman to integrate the database modifications we've done with the site's database. We will also determine what it will take to automate the app database generation.  
  4. Cleanup & update the database data. I will help to clean up the database with the interns as necessary. We need to work with the Business members to make sure that their data is up to date & accurate. Also we need to show the members how the couponing works, as well as get logo jpegs if possible.  
  5. Get final icon & splash page graphics. I will coordinate with Judi on this one.  
  6. Outreach to Members about the app. We need to generate an email, blog posting or something that tells Member business' about the upcoming app. I suggest that we create a notification for all members, and then follow up with the gold members (60 out of approx 400 Members) personally to show them the app & get both their data updated and discuss the couponing feature.  
  7. Start creating app store app page description. We need to create the verbage, screenshots etc for the description of the app found on the app store. Here's a couple of typical examples. Tomato Trouble Mountainview Mobile  
  8. Finalize details about couponing & enlist a Member as outsourced resource. We need the ability to generate coupon jpegs for Members if they need them. Heather Reed of Creative Fuel has been working with me on the couponing features, and she would be happy to be that resource for us.  
https://www.thinklocalsantacruz.org/c/members/edit/1307/0081ab121da8d93b6ee9d0a88150852db95b647f

Saturday, August 31, 2013

iOS File System Programing

Apple's main resource is File System Programming Guide

This is a typical directory location for a NSURL mainBundle file;
The Plist filename & directory is file://localhost/var/mobile/Applications/DA3AD182-B6BD-4782-8C53-10BB77FC8205/ThinkLocal.app/TLFMemberList.plist


Wednesday, August 28, 2013

Foolish Times Distribution Map

Tuesday, July 9, 2013

Turn-by-Turn Routing for your app

The following method takes the User's location and the destination's location and sends them to the iPhone's native Maps app for their Turn-by-Turn routing.  Most excellent!!

Looks like this:

The method:

- (IBAction)turnByRouting:(UIBarButtonItem *)sender {
    NSLog(@"Opens the native Map app's turn-by-turn navigation");

//business location
    // test location
    // CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(37.0469,-122.0308);


// Gets the coordinates from the single pinsArray object
    NSString *latitude = [[self.pinsArray objectAtIndex:0] objectForKey:@"latitude"];
    NSString *longitude = [[self.pinsArray objectAtIndex:0] objectForKey:@"longitude"];
    CLLocationCoordinate2D coords = CLLocationCoordinate2DMake([latitude
          doubleValue], [longitude doubleValue]);
      
    MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:coords addressDictionary:nil];
    MKMapItem *mapItem = [[MKMapItem alloc]initWithPlacemark:place];
  
//current location
    MKMapItem *mapItem2 = [MKMapItem mapItemForCurrentLocation];
      
    NSArray *mapItems = @[mapItem, mapItem2];
      
    NSDictionary *options = @{
        MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,
        MKLaunchOptionsMapTypeKey:[NSNumber numberWithInteger:MKMapTypeStandard],
        MKLaunchOptionsShowsTrafficKey:@YES
    };      
    [MKMapItem openMapsWithItems:mapItems launchOptions:options];
}



Thursday, June 20, 2013

JSON / RestKit API Notes

These are notes for installing and using REST (Representational State Transfer).  REST is an API that allows you to translate Web services into coreData within an iPhone app and back the other way.
At its core, RestKit is a system for binding your application's data model with a remote object representation retrieved via HTTP. RKGist tutorial RayWenderlich


CocoaPods - Is an library management tool used in Xcode in conjunction with REST.  It creates a Podfile textfile that creates the dependancies that you specify there.  It is built with the commandline tool.  These following Ray Wenderlich tutorials are great introductions;
open -e Podfile - opens the Podfile in textEdit for libraries & dependencies
pod install - installs new dependencies

SimpleURLConnections.xcodeProj -> Apple's demo using NSURLConnection GET (download) PUT/POST (upload) commands to create a very simple network connection to a server.

Cloning a repository for a GitHub project
  1. Open a terminal and change to the directory where you want the code
  2. Clone the repo by typing git clone git://github.com/dcgrigsby/luckynumbers.git
 git clone git://github repository URL - creates a clone of the project in the directory that you are in

Let's do a simple JSON tutorial first.
JSON - JavaScript Object Notation is a widely used framework for parsing data off the web.  Using this tutorial;
Apple now has it's own JSON implementation called - NSJSONSerialization class

A good source of data in either XML or JSON is The Geonames, geographical database with over 8 million entries. You can join their web service, and access huge data sets including WikaPedia.
Here some links you could find useful: username = clamb
GeoNames User Manual : http://www.geonames.org/manual.html
GeoNames Blog : http://geonames.wordpress.com
GeoNames Forum : http://forum.geonames.org
GeoNames Mailinglist : http://groups.google.com/group/geonames

3rd Party Framework that provides a wrapper class:
http://www.infinite-loop.dk/developer/ilgeonames/

Some examples of XML requests;
Returns all zipcode place names within 10km of zip code=95062 (Santa Cruz):http://api.geonames.org/findNet providesarbyPostalCodes?postalcode=95062&country=US&radius=10&username=clamb
Example for a tourism hierarchy, islands for the Canaries:
http://api.geonames.org/children?geonameId=2593110&username=clamb&hierarchy=tourism
Result : returns a list of wikipedia entries as xml document near Santa Cruz:
http://api.geonames.org/findNearbyWikipedia?lat=37&lng=-122&username=clamb





Sunday, June 9, 2013

Memory Management

This post contains a series of notes, links and tips on memory management in Objective-C.

Reference links
* Great intro to memory management - http://maniacdev.com/2009/07/video-tutorials-on-objective-c-memory-management
* Apple's Memory Usage Guidelines - https://developer.apple.com/library/mac/#documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html
* A truly great Instruments Tutorial - http://www.raywenderlich.com/23037/how-to-use-instruments-in-xcode


Notes
* retainCount is a property of NSObject that is used by the system to manage an object's memory.  It is essentially the count of other objects that have a reference to that object.
   [anObject retainCount] returns an integer retain count for anObject
   [anObject retain] increases the count by 1
   [anObject release] decreases the count by 1
   When the count = 0 the system deallocates the memory for that object
* Rule #1 - alloc, new & copy create a new object with retainCount = 1.  Whenever you create an object with one of these methods, your are responsible for releasing that object.
* autoRelease is a method that adds your object to the autoRelease pool where it is released at the end of a program cycle.  It simplifies your task of having to release your objects.
* Memory leaks are blocks of allocated memory that the program no longer references. Leaks waste space by filling up pages of memory with inaccessible data and waste time due to extra paging activity. Leaked memory eventually forces the system to allocate additional virtual memory pages for the application, the allocation of which could have been avoided by reclaiming the leaked memory. (by Apple's Guidelines above)
* For apps that use malloc, memory leaks are bugs and should always be fixed. For apps that use only Objective-C objects, the compiler’s ARC feature deallocates objects for you and generally avoids the problem of memory leaks. However, apps that mix the use of Objective-C objects and C-based structures must manage the ownership of objects more directly to ensure that the objects are not leaked. (by Apple's Guidelines above)



Tips
  • unbounded memory growth - This happens where memory continues to be allocated and is never given a chance to be deallocated.  Use heap shot analysis to troubleshoot (see rayWenderlich tutorial above)
  •  

Wednesday, March 27, 2013

Custom mapTiles and Building Maps in MapBox & TileMill

This is a quick mashup of details needed to build a custom map using;
  • Beautiful artistic map tiles from Stamen Design
  • Integrated into your own custom map tiles with TileMill
  • And built out as a completed annotated map with MapBox
This is a simple demo for building a small map of Farmer's Markets to be published in a local omnivore quarterly.

Embed code for Stamen watercolor map;

To use these tiles, just include our JavaScript alongside your favorite mapping library:
<script type="text/javascript" src="http://maps.stamen.com/js/tile.stamen.js?v1.2.1">
</script>

 Then, follow the instructions below for your preferred library:
OpenLayers is a hefty and featureful mapping library for use with a variety of GIS applications. View the example.

// replace "toner" here with "terrain" or "toner"
var layer = new OpenLayers.Layer.Stamen("watercolor");
var map = new OpenLayers.Map("element_id");
map.addLayer(layer);


Creating embedded code (iFrames) for custom maps

This is a description including code snippets of how to create embed code for other people to insert into their web pages.  It is based on the work we are doing with GPSVisualizer, but can be used to embed an URL that is available to an online server (like our SCNewspaperTaxi website, or a file with a URL on our Google Drive).

This is the FAQ for GPPSVisualizer:
By far the easiest solution is to put the map in an "inline frame" using the <IFRAME> tag. This creates a "window" in your page into which you can load another file (more info about IFRAMEs). The advantage of doing this is that the DIVs and margins and styles and whatnot will be completely isolated from the rest of the structure of your page; also, you don't have to edit the attributes of the <BODY> or <HTML> tags, which you would have to do if you tried to merge the GPS Visualizer code into your Web page. (The only disadvantage, and one which would only affect "power users," is that if you want to create objects that interact with the map -- for instance, a list of waypoints, or a control that will re-center the map -- those cannot be outside the IFRAME.)
Another advantage to IFRAMEs (as opposed to cutting and pasting bits of HTML into your page) is that you can place as many of them on your page as you want; because they are isolated from each other, there shouldn't be any conflicts even if all the maps have identically named parts.


Here's a sample <IFRAME> tag; the anchor in the middle will only be displayed if the browser does not support inline frames:
<iframe src="my_map.html" width="600" height="400" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">
 <a href="my_map.html">Click here for the map</a>
</iframe>


Here’s an example from a Google Maps embed code:
</iframe>
<br /><small>View <a href="https://maps.google.com/maps/ms?msa=0&amp;msid=204112771159932432535.0004d6a3eb52759422f2e&amp;hl=en&amp;ie=UTF8&amp;ll=36.987644,-121.759922&amp;spn=0.271253,0.722587&amp;t=m&amp;iwloc=0004d6a410726c0cee96f&amp;source=embed" style="color:#0000FF;text-align:left">Santa Cruz Beer Map </a> in a larger map</small>


demo map URL saved in SCNewspaperTaxic.com
http://santacruznewspapertaxi.com/wp-content/uploads/2013/03/xxxxDistributionGeocoded04.html


Here’s the code for our 1st iFrame (hopefully):
<iframe src="http://santacruznewspapertaxi.com/wp-content/uploads/2013/03/xxxxDistributionGeocoded04.html" width="600" height="400" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">
 <a href="http://santacruznewspapertaxi.com/wp-content/uploads/2013/03/xxxxxxDistributionGeocoded04.html">Click here for the map</a>
</iframe>



Creating embedded code (iFrames) for custom maps

This is a description including code snippets of how to create embed code for other people to insert into their web pages.  It is based on the work we are doing with GPSVisualizer, but can be used to embed an URL that is available to an online server (like our SCNewspaperTaxi website, or a file with a URL on our Google Drive).

This is the FAQ for GPPSVisualizer:
By far the easiest solution is to put the map in an "inline frame" using the <IFRAME> tag. This creates a "window" in your page into which you can load another file (more info about IFRAMEs). The advantage of doing this is that the DIVs and margins and styles and whatnot will be completely isolated from the rest of the structure of your page; also, you don't have to edit the attributes of the <BODY> or <HTML> tags, which you would have to do if you tried to merge the GPS Visualizer code into your Web page. (The only disadvantage, and one which would only affect "power users," is that if you want to create objects that interact with the map -- for instance, a list of waypoints, or a control that will re-center the map -- those cannot be outside the IFRAME.)
Another advantage to IFRAMEs (as opposed to cutting and pasting bits of HTML into your page) is that you can place as many of them on your page as you want; because they are isolated from each other, there shouldn't be any conflicts even if all the maps have identically named parts.


Here's a sample <IFRAME> tag; the anchor in the middle will only be displayed if the browser does not support inline frames:
<iframe src="my_map.html" width="600" height="400" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">
 <a href="my_map.html">Click here for the map</a>
</iframe>


Here’s an example from a Google Maps embed code:
</iframe>
<br /><small>View <a href="https://maps.google.com/maps/ms?msa=0&amp;msid=204112771159932432535.0004d6a3eb52759422f2e&amp;hl=en&amp;ie=UTF8&amp;ll=36.987644,-121.759922&amp;spn=0.271253,0.722587&amp;t=m&amp;iwloc=0004d6a410726c0cee96f&amp;source=embed" style="color:#0000FF;text-align:left">Santa Cruz Beer Map </a> in a larger map</small>


demo map URL saved in SCNewspaperTaxic.com
http://santacruznewspapertaxi.com/wp-content/uploads/2013/03/xxxxDistributionGeocoded04.html


Here’s the code for our 1st iFrame (hopefully):
<iframe src="http://santacruznewspapertaxi.com/wp-content/uploads/2013/03/xxxxDistributionGeocoded04.html" width="600" height="400" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">
 <a href="http://santacruznewspapertaxi.com/wp-content/uploads/2013/03/xxxxxxDistributionGeocoded04.html">Click here for the map</a>
</iframe>



Monday, March 25, 2013

Dynamic Linking of Map & Spreadsheet

The following instructions allows the map generated by GPSVisualizer to be dynamically linked with the spreadsheet that generated the original data. This means that all changes made to the 'control' spreadsheet will automatically appear in the map every time it is reloaded.  Very cool, again many thanks to: Adam Schneider.

Accessing the spreadsheet:
  1. The file should be saved as a doc.google.com/spreadsheet and formatted with lat, long and other data as necessary to generate the popups
  2. Open the file, Goto File, Publish to the Web, Start publishing now or Republish now (if the file is already published)
  3. Copy, <ctrl>C the resulting URL for pasting into the GPSVisualizer script

Building the Map:
  1. Next we go to the GPSVisualizer site and goto Make a Google map from a GPS file
  2. Paste <ctrl>V the Spreadsheet URL into the Or a URL that the map will load dynamically box in the lower left corner
  3. Expand the WayPoint Options section and changes as necessary, including;
  4. Icon:
  5. Default color marker:
  6. Synthesize name: {name}
  7. Synthesize description: Contact: {contact}<br>Phone: {phone} generates a custom form in the popup
  8. Press Draw the Map button and cross your fingers
  9. Goto the resulting map and then select the save your Google map link and save the file with an appropriate name & as a simple .HTML file
  10. That file can now be opened in your browser, and ever time you update the spreadsheet, and press Republish now the map file will update with the new data (after you Reload the map page)
 
Or a URL that the map will load dynamically: Os r 


a URL that the map will load dynamica

Thursday, March 7, 2013

Signing an emailed form

I've been receiving a lot of NDAs and other forms for which people want my 'John Hancock' signature.  Some have gone as far as insisting that I print the form, sign it and then scan it back to them! Talk about a pain.
So I found a great way to provide an image of your signature that can be placed on the form.
The form need to be in .PDF format and you need to open it in PREVIEW.  Then follow the instructions below, and you get something like this:
Sign a PDF document
You can take a picture of your handwritten signature and then add it to any PDF document.

HideTake a picture of a signature
Choose Preview > Preferences, click Signatures, and then click Create Signature.
If a signature already exists, you can choose the Create Signature command from the Signature pop-up menu in the Annotations toolbar.

Follow the instructions displayed on screen.
Make sure your signature fills the box on the left and sits on the blue baseline.
When the signature preview looks correct, click Accept.

Sign a document
Click Annotate in the toolbar, if you don’t see the annotations bar.
From the Signature pop-up menu, choose a signature.
Click the location where you want the signature to appear.
If you click a line, Preview shrinks the signature, if necessary, to fit on it.

Tuesday, February 26, 2013

Common Xcode erros & their remedies

Here are a few of the errors that I've come across, their descriptions and fixes;

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -predicateFormat cannot be sent to an abstract object of class NSPredicate: Create a concrete instance!'*** 
This error comes up when you try to pass an invalid method or value the an object

Thread 1: EXC_BAD_ACCESS(code=1, address= 0xb1f034fe
This error is usually from trying to access a deallocated object


Friday, February 22, 2013

what's in a widget

This is a great widget that I would like to create.  What's it written in?

Friday, February 1, 2013

The executable was signed with invalid entitlements.

This classic error with the following text;
The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile.
you need to make sure they are the same.
  • Goto Xcode-Window-Organizer-Devices and then goto the connected device's Provisioning Profiles tab.
  • Note the name of the currently valid profile;
  • In Xcode goto program-target-Project-Build Settings-Code Signing and copy the appropriate profile name into the Code Signing Identity field and also in it's children
Recompile & Off You Go!

Sunday, January 27, 2013

Creating maps with GPSVisualizer

Steps for creating a map from a spreadsheet using the very useful GPSVisualizer website brought to us by Adam Schneider

Geocoding your data (getting latitude / longitude from addresses)
  • Open spreadsheet, and make sure file has appropriate data filled out.  In particular make sure that the are address, city, state columns or latitude longitude fields complete and correct.
  • Save the spreadsheet as a CSV file (Comma Separated Variable)
  • Goto GPSVisualizer and open up their Geocode an Address page
  • Goto 3,Geocode simple tabular data, and select the text/GPX conversion utility
  • Paste your CSV file into the file field and set Plain text delimiter:comma    Plain text output  units: US and press Convert to allow the utility to add latitude & longitude to your file
  • Save the resulting .csv file to the appropriate directory
  • Review the file to note bad addresses and suchoogle Drive and set appropriate sharing.
Creating the KML file (these files have waypoints & track data)
  • Download the distribution spreadsheet as a .CSV file for uploading into the GPSVisualizer
  • Goto GPSVisualizer and open up their Make a Google Earth map page
  • Upload the CSV file to the applet and modify settings in particular advanced waypoint options, as required
  • Press CREATE KML file button
  • Download the resulting .kml file to your drive and uploading to Google Maps
Creating the Google map from within Google Maps
  • Goto to your Google Maps and press My Places button
  • Press Create Map button and enter import routine
  • Browse for and Upload the .KML file and the map should build.
  • Check data and correct data a necessary
Done!

Modifying the spreadsheet & Geocoding additional addresses
  • Add the new addresses per the spreadsheets format
  • Copy the range of new places (name,address,city,state,country)
  • Goto GPSVisualizer and open up their Geocode an Address page
  • Paste the copied range into the Data box 
  •  
Adding Custom or colored icons to the KML file
The GPSVisualizer routine will NOT encode colored (or Customized) icons into the resulting Google Maps version (it works fine for Google Earth implementations).  This procedure shows how to customize the colors (or look) of the placemarks.
  • Goto the downloaded KML file and open in TextEdit
  • Paste the iconStyle you want to use into the top of the file.  The template below is style23 a green icon.
  <Style id="style23">
    <IconStyle>
      <Icon>
        <href>http://maps.gstatic.com/mapfiles/ms2/micons/green.png</href>
      </Icon>
      <scale>1.000000</scale>
    </IconStyle>
    <LabelStyle>
      <color>FF008000</color>
    </LabelStyle>
  </Style>
  • Paste the string style23 into each's addresses styleURL field like below that should be green
<styleUrl>#style23</styleUrl>






Friday, January 11, 2013

Memory leaks

Even with ARC (Automatic Reference Counting) an app can have memory leaks which can totally foul up an app.  Typical signs of leaks include;
  • slowing of the apps animation, view transitions, etc
  • locking up the app and or device (see Turning off your locked up iPad)
This post is a quickstart guide for using Xcode's Instruments specifically  to find those leaks.
From within Xcode;
  • Select Xcode-Open Developer's Tools-Instrument
  • Then select your instrument from the popup - Leaks in our case
  • Size the Allocation & Leaks strip charts appropriately and
  • from the List box in the upper left select Choose Target-appName on the device
  • Press Record n Stop button to start & stop the app
Allocations should reach some level & then stop.  If you have leaks they show as red bars, and the allocations count will keep rising.  You can isolate where the leaks are by looking into the stack when the leaks occur.  Fix and rerun the app.

Apple's Instruments User Guide is the place to start learning about these tools. Also see the Xcode 4 User Guide to use with Xcode.

Within Xcode the call stack can be investigated from the Debugger toolbar as in this snapshot


 Stepping back thru the vertical call stack can give an indication where the code failed.