Tuesday, April 08, 2014

iOS 7 Training Course by Stanford University

iOS 7 training course, Developing iOS Apps for iPhone and iPad, offered by Paul Hegarty, University of Stanford was published on Oct 28, 2013 at iTunesU. I did not realized its availability until today. Actually WWDC 2014 will be on June 2, 2014. New iOS features will be announced in about two months time.

Here is the description of the course:

Updated for iOS 7. Tools and APIs required to build application for the iPhone platform using the iOS SDK. Users interface designs for mobile devices and unique user interactions using multi-touch technologies. Objective-oreiented design using model-controller paradigm, memory management, Objective topics includes: objective-oriented database API, animation, multi-threading and performance considerations.

Prerequisites: C language and objective-orianted programming experience

Recommended: Programming Abstractions.

Offered by Stanford School of Engineering and released with Creative Commons BY-NC-SA licenses.  If you have disability-related accessibility question, please email cs193p-accessibility@lists.stanford.edu.

Couse Outline

I. Couse Introduction, Overview of iOS, MVC Objective-C
II. Xcode 5
III. Objetive-C
IV. Foundation, Attributed Strings
V. View Controller Lifecycle

This course is on the top of Cources in iTunesU.




Today I finished the first course. I am going to update this blog with my progress.



NameFinished DateNotes
1. Class Logistics, Overview of iOS, Objective-C2014-04-08MVC is explained in 1st lesson!
2. Xcode 52014-04-09Created card matching game (Matchismo) project in Xcode 5
3. Objective-C2014-04-09Updated the project with model class CardGame class. Demonstrated communication between Controller and Model & View in Xcode.
4. Foundation and Attributed Strings2014-04-09More on Objetive-C, id, introspection(query id class type and method implementation; Foundation: NSObject, NSArry, NSNumber, NSData, NSDIrectionary, NSUserDefaults, NSRange, UIFont UIColor, NSAttributedString(new in iOS 7).
5. View Controller Lifecycle2014-04-10Continue on attributed string with UITextView (new attributed string for the view). View controller lifecycle and Notification (radio station communication mechanism) with new Attributor demo project.
6. Polymorphism with Controllers, UINavigation, UITableBar2014-04-10Polymorphism: Subclass and abstract class; MVCs controlled by navigation or tab controllers.
7. View and Guestures2014-04-11Views are most often constructed in Xcode graphically. Override drawRect:for customized UIView class, to draw your own staff.  Use UIBezierPath to draw.  Drawing text: UILabel, NSAttributedString.

UIGuestureRecgonizer  for accept inputs: pan, pinch,  rotation, swipe, and tap.

Demo: SuperCard: draw card in customized view class, and handle swipe gesture to turn card, pinch gesture to scale card image.
8. Protocols, Blocks and Animation2014-04-12First two are very important coding practices in Objective-C. Block of codes can be attached to methods as a way for customized implementation. iOS 7 adds two ways to do animation, view animation methods and animator with behaviors. Demo DropIt project shows the power of animations.
9. Animation and Autolayout2014-04-13Continued the previous demo on animation: less tippy, add trap to dropping view with line.
Autolayout is powerful in iOS 7. Paul explained three ways to do it in Xcode: 1. use guidelines, 2. tools in Xcode bottom, and 3. control-click.
Demo: update previous Attibutor project with auto layout, simple and nicely done!


10. Multithreading, Scroll View2014-04-13iOS 7 utilizes blocks to make multithreading much easy to manage and control. Demo project imaginarium shows downloading image with multithreading technique and scroll view to host image with zooming feature.
11. Table View and iPad2014-04-14Table view has been in iOS since iPhone first version. It is a very popular way to show data. Paul showed activity indicator for table view. This may be something new in iOS 7. The second part is about iPad. Demo: universal app Shutterbug displaying photos from Flikr.
12. Documents and Core Data2014-04-14Document is used for storage, here Core data is using it as storage. Core data has been in iOS for long time, but it has been updated extensively. Xcode provides working nice UI and classes for data creation, update, deletion and query. Paul explains basics in a clear layout logic.
13. Core Data and Table View2014-04-15This lecture contains a lot of information about core data, radio notification pub and sub, application delegate, and background execution. All are explained quickly in Photomanian project.
14. UIApplication, Network Activity2014-04-16Briefly on UIApplication: sharedApplication and delegate. One property networkActivityVisible, maybe confusing when you have a lots of activities and turning it on or off. Demo Photomanian, iPad, show photos, and popover. Maps: core classes for Maps. Tip on working on iPad or iPhone, copy and paste storyboard!
15. MapKit and Embed Segue2014-04-16Quickly through MapKit classes. Continued to Photomanian demo, iPhone: replaced PhotoByPhotographer's tableview with mapvuew; iPad: two ways to show maps and photos, first one similar to iPhone's flow out, and second embed view by embed segue, very cool!
16. Modal Segue and Text Field2014-04-17Last segue in this lecture. The only difference is unwise segue, set action to storybord green icon in view. Text field is for text input in one line. Demo: Photomanian, add photos from camera (no camera information in this class) by modal segue, alert view, cancel or add a photo to photographer.

Also showed how to start CLocation manager and to get location of latitude and longitude. 
17. Camera, Core Motion, Application Lifecycle2014-04-18Camera: continued to demo Photomaian to add "Take photo" to new photo view.

In second half, Paul explained Motion APIs first, then he demoed a project Bouncer with no storyboard, all in codes, redBlock and blackBlock to bounce based on animation and motion manager. 
18. Localization, Adding UI to Settings2014-04-18Paul showed tick to localize strings: search for @" in .m, #define for localization, and then gesturing in finder to generate strings. Xcode provides UI for stroryboard localization. Use . for localized strings. Demo: Photomanian localization

For settings, Paul uses Bouncer as demo to as slider for alacrity setting.


Read More...

Monday, April 07, 2014

PS Function: Convert Collection of PSObjects

PS Table-view is a very useful view to present collection of PSObjects. This works well with PSObejects with just simple and single value properties, such as name, age, telephone number etc. However, if there is any properties with collections, the layout may be too for for those long list of collection objects.

I find out a great way to convert collection of PSObjects with collections as its properties. It works very well to break collection of values as multiple lines in column so that the layout of table view is much tight and clean.

Here is the function:

#FileName: UtilCollection.ps1
#================================
#FUNCTION LISTINGS
#================================
Function ConvertPSObjectCollection {
<#
   .SYNOPSIS
       Gets a converted collection of PSObjects so that the converted
   collection can be nicely displayed in table-view.

   .DESCRIPTION
       This function will convert a collection of PSObjects with
   one or more array properties to a collection of PSObjects so
   that the colleciton can be output to a nice and tight table view.
   
   The input collection contains PSObjects with one or more array
   property element. Normally array elements are too wide to be displayed
   in a table-view. By converting collection, the returned colection
   can be viewed nicely in table-view.
   
   This function is based on SO solution http://stackoverflow.com/questions/22723954/powershell-autosize-and-specific-column-width

   .PARAMETER CollectionPSObjects
       Mandatory. Collection of PSObjects, PSObject have one or more
   property of array data.

   .INPUTS
       Parameters above

   .OUTPUTS
       A collection of converted PSObjects with same prorperties
   but array elements as rows in the collection so that the
   collection can be nicely formated output to a table view.

   .NOTES
       Version:        1.0
       Authors:        David Chu
       Creation Date:  10/04/2014
       Purpose/Change: Initial function development

   .EXAMPLE
       $myCol = @(
       (New-Object –TypeName PSObject –Prop @{'id'='01';'name'='a';'items'=@(1,2,3);'others'=@('SampleA1','SampleA2')}),
       (New-Object –TypeName PSObject –Prop @{'id'=@('02a','02b');'name'='b';'items'=@(1,2,3);'others'=@('SampleB1','SampleB2','SampleB3','SampleB4','SampleB5')}),
       (New-Object –TypeName PSObject –Prop @{'id'='03';'name'=@('c1','c2');'items'=@(1,2,3);'others'='SampleC'})
       )

 $myCol1 = ConvertPSObjectCollection $myCol
 $myCol1 | FT ID,Name,Items,Others -AutoSize
#>
   [CmdletBinding()]
Param (
[Parameter(Mandatory=$true)] $CollectionPSObjects
)
Process {
 $m_result = $CollectionPSObjects | %{
     $Current = $_
     $Members = $_|GM|?{$_.MemberType -match "Property"}| `
     Select -ExpandProperty Name
     $Rows = ($Members|%{$current.$_.count}| `
     sort -Descending|Select -First 1)-1
     For($i=0; $i -le $Rows;$i++){
         $LoopObject = New-Object PSObject -Property `
       @{$($Members[0]) = if($Current.$($Members[0]).count -gt 1) { `
           $Current.$($Members[0])[$i] `
         } else{ `
           if(!($i -gt 0)){ `
             $Current.$($Members[0]) `
           }else{ `
             $Null `
           } `
         } `
       }
         If($Members.Count -gt 1){
             $Members[1..$Members.count]|%{
                 Add-Member -InputObject $LoopObject `
           -MemberType NoteProperty `
           -Name $_ `
           -Value $(if($Current.$_.count -gt 1) { `
             $Current.$_[$i] `
             }else { `
               if(!($i -gt 0)) { `
                 $Current.$_ `
               }else{ `
                 $Null `
               } `
             } `
           )
             }
         }
     $LoopObject
     }
 }

 return $m_result
 }
}

References



Read More...

Wednesday, April 02, 2014

Three Shortcuts of PowerShell Script

Recently I have been writing PS codes at work. PS is a really good and powerful script language in Windows environment. I have never learned it systematically or from basic concept to advanced level.  Based on my other programming skills, I just pick it and use it at work. In most cases, I just do the internet search for solutions if I don't have clue how to resolve my problems. Therefore, I have been on and off depending on my work requirements.

Still I don't know some very basic concepts. Here are three most commonalty used code cases:

%{....}
@{....}
?{....}


I just use them based on other people's codes. For these three shortcuts, I have trouble to google explanations. Finally, last week, I got an answer from SO.

%{...}: ForEach{}
@{...}: Constructor for hash table
?{...}: shortcut for Where {....}

References


  • SO comment discussion on Francis Padron's quetsion.

Read More...