Updated to Swift & Xcode 6: Unleash Your Inner App Developer – Part 6: Finishing the Prototype

Step-by-step instructions for creating an iOS App with Swift and Xcode 6.


All the best!
Kevin McNeish
Author: iOS App Development for Non-Programmers book series
Twitter: @kjmcneish

Awkward file and folder names

Spent some time today dealing with a situation where there were special characters – namely [ ] in folder a file names

£> Get-ChildItem -Path C:Test

    Directory: C:Test

Mode                LastWriteTime     Length Name
—-                ————-     —— —-
d—-        21/01/2015     17:58            Awkward [One]
d—-        21/01/2015     17:59            Simple One


Each folder has 3 files:

File 1.txt
File 2.txt
File 3.txt


Get-ChildItem -Path ‘C:TestSimple One’

will work and show you the contents. When I’m typing paths like this I let Tab completion do the work. Type c:test and use the Tab key to cycle round the available folders.


This gives

£> Get-ChildItem -Path ‘C:TestAwkward `[One`]’
Get-ChildItem : Cannot find path ‘C:TestAwkward `[One`]’ because it does not exist.
At line:1 char:1
+ Get-ChildItem -Path ‘C:TestAwkward `[One`]’
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:TestAwkward `[One`]:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand


Unfortunately, the construct produced by Tab completion doesn’t work.  You need to double up on the back ticks so that it functions as an escape character.

Get-ChildItem -Path ‘C:TestAwkward “[One“]’


But that only shows you the folder not the contents.

Get-ChildItem -Path ‘C:TestAwkward “[One“]*’


Get-ChildItem -Path ‘C:TestAwkward “[One“]’ -Include *


Will show you the contents of the folder.


But bizarrely

Get-Content -Path ‘C:TestAwkward `[One`]File 1.txt’

Works. As does

Copy-Item -Path ‘C:TestAwkward `[One`]File 1.txt’ -Destination c:test2


By using back ticks and quotes you can get round most problems like this. Other characters that cause similar problems are commas and quote marks.

Best advice of all – don’t use those awkward characters in your file names if you can possibly avoid it.

Removal instructions for SuperPlusRadio

What is SuperPlusRadio?

The Malwarebytes research team has determined that SuperPlusRadio is a browser hijacker. These so-called “hijackers” manipulate your browser(s), for example to change your startpage or searchscopes, so that the affected browser visits their site or one of their choice. This one also displays advertisements.


Spybot Search & Destroy Weekly Update – January 21, 2015


++ Ad.Jpdesk + Firseria + InstallMonetizer ++ SwagBucks.Toolbar + Win32.InCore
+ InffinityInternet ++ IntelliDownload
+ Cridex.kb + Win32.Downloader.HicrazykA + Win32.ZBot
Total: 2602969 fingerprints in 813835 rules for 7396 products.


Lesser-Known NHibernate Features: Result Transformers

A result transformer, in NHibernate, is some class that implements the IResultTransformer interface:

   1: public interface IResultTransformer

   2: {

   3:     IList TransformList(IList collection);

   4:     Object TransformTuple(Object[] tuple, String[] aliases);

   5: }

Most query APIs, except LINQ, support specifying a result transformer. So, what is a result transformer used for? Just what the name says: it turns the values obtained from a query into some object. Normally, we just let NHibernate transform these values into instances of our entities, but we may want to do something different, either because we haven’t mapped some class that we want to use, or because we are not returning all of the entity’s properties, etc.

NHibernate includes some result transformers:

  • AliasToBeanResultTransformer: allows to transform a result to a user specified class which will be populated via setter methods or fields matching the alias names;
  • AliasToBeanConstructorResultTransformer: identical to AliasToBeanResultTransformer, but we specify a constructor for creating new instances of the target class;
  • AliasToEntityMapResultTransformer: returns a dictionary where the keys are the aliases and the values the corresponding columns;
  • AliasedTupleSubsetResultTransformer: ignores a tuple element if its corresponding alias is null;
  • CacheableResultTransformer: used to transform tuples to a value(s) that can be cached;
  • DistinctRootEntityResultTransformer: for joined queries, returns distinct root entities only;
  • PassThroughResultTransformer: just returns the row as it was obtained from the database;
  • RootEntityResultTransformer; returns the root entity of a joined query;
  • ToListResultTransformer: transforms each result row from a tuple into a IList, such that what you end up with is a IList of ILists.

All of these can be obtained from static properties in class NHibernate.Transform.Transformers. NHibernate implicitly uses some of these, for example, LINQ queries always use DistinctRootEntityResultTransformer.

It is easy to build our own transformer. Have a look at the following example:

   1: public class ExpressionsResultTransformer : IResultTransformer

   2: {

   3:     private readonly Type type;

   4:     private readonly Func<Object> constructorFunc;

   5:     private readonly ConstructorInfo constructor;

   6:     private readonly Object[] parameters;

   7:     private readonly Dictionary<Int32, String> expressions = new Dictionary<Int32, String>();

   8:     private PropertyDescriptorCollection props;


  10:     public ExpressionsResultTransformer(ConstructorInfo constructor, params Object[] parameters)

  11:     {

  12:         this.constructor = constructor;

  13:         this.parameters = parameters;

  14:     }


  16:     public ExpressionsResultTransformer(Func<Object> constructorFunc)

  17:     {

  18:         this.constructorFunc = constructorFunc;

  19:     }


  21:     public ExpressionsResultTransformer(Type type)

  22:     {

  23:         this.type = type;

  24:     }


  26:     private Object CreateInstance()

  27:     {

  28:         if (this.type != null)

  29:         {

  30:             return (Activator.CreateInstance(this.type));

  31:         }

  32:         else if (this.constructorFunc != null)

  33:         {

  34:             return (this.constructorFunc());

  35:         }

  36:         else

  37:         {

  38:             return (this.constructor.Invoke(this.parameters));

  39:         }

  40:     }


  42:     public ExpressionsResultTransformer Add(Int32 index, String property)

  43:     {

  44:         this.expressions[index] = property;

  45:         return (this);

  46:     }


  48:     public ExpressionsResultTransformer Add(params String[] properties)

  49:     {

  50:         foreach (var property in properties)

  51:         {

  52:             this.Add(property);

  53:         }


  55:         return (this);

  56:     }


  58:     public ExpressionsResultTransformer Add(String property)

  59:     {

  60:         var max = this.expressions.Keys.DefaultIfEmpty(-1).Max();

  61:         return (this.Add(max + 1, property));

  62:     }


  64:     public static ExpressionsResultTransformer Add<T>(params String[] properties) where T : new()

  65:     {

  66:         return (new ExpressionsResultTransformer<T>().Add(properties));

  67:     }


  69:     #region IResultTransformer Members


  71:     IList IResultTransformer.TransformList(IList collection)

  72:     {

  73:         return (collection);

  74:     }


  76:     Object IResultTransformer.TransformTuple(Object[] tuple, String[] aliases)

  77:     {

  78:         var entity = this.CreateInstance();


  80:         if (this.props == null)

  81:         {

  82:             this.props = TypeDescriptor.GetProperties(entity);

  83:         }


  85:         foreach (var expression in this.expressions)

  86:         {

  87:             this.props[expression.Value].SetValue(entity, tuple[expression.Key]);

  88:         }


  90:         return (entity);

  91:     }


  93:     #endregion

  94: }


  96: public sealed class ExpressionsResultTransformer<T> : ExpressionsResultTransformer where T : new()

  97: {

  98:     public ExpressionsResultTransformer() : base(typeof(T))

  99:     {

 100:     }


 102:     public ExpressionsResultTransformer(Func<T> constructor) : base(new Func<Object>(() => (Object) constructor()))

 103:     {

 104:     }


 106:     public ExpressionsResultTransformer(ConstructorInfo constructor, params Object[] parameters) : base(constructor, parameters)

 107:     {

 108:     }

 109: }

The TransformTuple method is the one used to turn each returned record into an instance of something. TransformList is called at the end, when all the records have been processed.

The ExpressionResultTransformer class allows us to select which indexes, in the database record, map to which properties in some entity. For our convenience, it offers a number of options to construct an instance (type, constructor + parameters and delegate). We would use it like this:

   1: var products = session.CreateSQLQuery("select p.Name, p.Price, p.ProductId from Product p").SetResultTransformer(ExpressionsResultTransformer.Add<Product>("Name", "Price", "ProductId")).List<Product>();

Resetting the Windows firewall on SBS 2008

Because the attachments were mangled a bit in the migration and because I’ve had several requests for this, I’m reposting the default settings for a SBS 2008 firewall on the server.

FirewallFileszipped up

So instead of this post – http://blogs.msmvps.com/bradley/2009/06/03/the-default-sbs-2008-firewall/

Use that link above

How to Change Owner of File, Folder, Drive, or Registry Key in Windows 10

The owner of an object (ex: file, folder, drive, or registry key) has the right to allow or deny access to that resource. Although members of the Administrators group and other authorized users also have the right to allow or deny access, the owner has the authority to lock out non-administrator users, and then the only way to regain access to the resource is for an administrator or a member of the Restore Operators group to take ownership of it. This makes the file or folder owner important with respect to what permissions are allowed or denied for a given resource.

The default owner of an object is the person who creates the resource. Ownership can be taken or transferred in several ways. The current owner of an object can transfer ownership to another user or group. A member of the Administrators group can take ownership of an object or transfer ownership to another user or group—even if administrators are locked out of the resource according to the permissions. Any user with the “Take Ownership” permission on the object can take ownership, as can any member of the “Backup Operators” group (or anyone else with the “Restore Files And Directories” user right, for that matter).

This tutorial will show you different ways to change the owner (take ownership) of a file, folder, drive, or registry key to any user or group in Windows 10.

Read more…

Data Storage Maturity Model

There are many ways of storing data when developing applications, some more mature and capable than others. Storing data of some sort or another in an application is common. Extremely common to be exact as almost every application out there needs to store data is some way or another. After all even a game usually stores the users achievements.

But it’s not games I am interested in. Sure they are interesting to develop and play but most developers I know are busy developing line of business (LOB) applications of some sort or another. One thing line of business application have in common is they work with and usually store data of some sort.

Data Storage Maturity Model

When looking at data oriented applications we can categorize data storage architectures based on different characteristics and capabilities.


Level 0: Data Dumps

The most basic way of working with data is just dumping whatever the users works with in the UI to some proprietary data file. This typically means we are working with really simple Create Read Update Delete (CRUD) type of data entry forms and not even storing the data in a structured way. This is extremely limited in capabilities and should generally be avoided at all costs. Any time you have to work with a slightly larger data set or update the structure you are in for a world of hurt.


Level 1: Structured Storage

At level 1 we are still working with CRUD style data entry forms but at least we have started using a formal database of some sorts. The database can be a relational database like SQL Server or MySQL but a NoSQL database like MongoDB is equally valid. While data database used allows us to do much more the user interface is not much better. We are still loading complete objects and storing them in a CRUD fashion. This might work reasonably well in a low usage scenario with a low change of conflicts but is really not suitable for anything more complex than a basic business application. We are only storing the current state of the data and as the database stores whatever is send from the UI, or business processing code, there is no sense of meaning to any change made.


Level 2: Command Query Responsibility Segregation

When we need to develop better and more complex business applications we really should use Command Query Responsibility Segregation (CQRS) as minimum. In this case we separate the read actions from the write actions. We no longer just send an object to be stored from the user interface to the back end but we are sending commands to update the data. These commands should be related to business actions the application works with. So in other words if a business analyst sees the command names he should be able to make sense of what they do without looking at the code implementations.

While this is a lot better we are still only storing the current state of the data. And that is the problem as it can be very hard to figure out how something got to be in a given state. So if a users detects that something is wrong with the data and suspects a bug in the program we might just have a hard time figuring out how it got to be that way. And once we do fixing the issue might be extremely hard as well.

There are other limitations with just storing the current state like not being able to produce reports, or only at great difficulty, the ask for. Or possibly alter business rules after the fact. And if you think that doesn’t happen just try working on a large government project where the slowness of the decision process means that rules are only definitely updated after the fact.


Level 3: Event Sourcing

The most advanced level to be working at is using Event Sourcing (ES). An events sourced application resembles a CQRS style application in a lot of ways except for one vital part. With an Event Sourced application we are no longer storing the current state of the data but we are storing all events that lead up to this. All these events are stored as one big steam of changes and are used to deduce the current state of the data in the application. These events typically never change once written, after all we don’t change history (although our view of it might change over time). This has some large benefits as we can now track exactly how the state came to be as it is making it easier to find bugs. And if the bug is in how we used those business events that we can fix the bug and often that is enough to deduce the correct state.

The usual queries done in an application are much harder on an event stream. In order to fix that issue the events are usually projected out to a read model making querying much easier. This read model it normally stored in some appropriate database like SQL Server or a NoSQL database but could also just be kept in memory. However the event stream is the true source of the truth and not the projections as these are just a derived result. This means we can delete all projections and completely rebuild them from the existing events resulting in much more flexibility. Need to do an expensive query in version two of an application? Well just create a projection designed for that purpose and rebuild it from all previously stored events. This is similar to our view of history changing.

There are some more benefits from storing events instead of just the current state. We can now do temporal queries, or queries over time, on how the data got to be how it is. These kind of queries have lot of goals like for example fraud detection. Another possibility is displaying the state at any previous point in time and running reports or analysis on the data as it was then.



It’s kind of hard to say at what level you should be working. Level 0, limited as it is might be appropriate for your application. Lots of applications are at level 1 and just basic forms over data CRUD applications. In some that might be appropriate but in a lot of cases that is actually sub optimal. Level 2 with CQRS is a pretty sweet place to be. You can capture the business intent with command and have a reasonable flexibility. At level 3 with event sourcing you gain a lot of flexibility and strength. If you are doing a more complex business application you should be working on this level. But as always there is no free lunch so don’t go there is the application is really not that complex :-)



Surface Resources for IT Pros

For IT Pros, here are a couple of terrific resources for you.

Surface for IT Pros – Surface blog on TechNet – new in November 2014

Surface Technical Guidance, Help, and Support – TechNet – Latest downloads and news.

Surface Pro 3 Deployment Administration Guide

Windows 10 Technical Preview – Four key new features

This article highlights four major new features for this new version for Windows currently in development 


QUOTE: The Windows 10 Technical Preview has now been out for a few months, and we can soon expect an updated build of Microsoft’s flagship operating system. What can longtime Windows users expect? Let’s look at some of the most interesting desktop- and enterprise-oriented Windows 10 features that users coming from Windows 7 and Windows 8.1 will immediately notice and enjoy.

1. New Spartan web browser - This may complement or even replace Internet Explorer in the future, with voice activation commands & embedded sub-browser modes

2. Cortana Voice activation system – Microsoft’s version of Siri is expected to make it into Windows 10, giving users the ability to control their computer, ask questions, conduct Web searches, set appointments and other reminders, and more by simply talking in a natural voice to their machine.

3. Classic Start menu returns – to provide a logical, non-full-screen place to launch applications and execute searches. Perhaps most importantly, users will go to the Start menu to log off and turn off their PCs

4. Continuum Device Unification – shifts the user interface based on what type of device the user is currently running.  When Keyboard is enabled, windows desktop mode is invoked, but when disconnected the device switches to Modern tile interface mode

CryptoWall 3.0 – New Variant emerges

Two months after the shutdown for version 2.0, a newly designed variant of the CryptoWall Trojan Horse has recently surfaced.  Users should avoid clicking suspicious email or website links and ensure they are fully patched and updated on AV protection.  Backups of data are always important and infected users should seek methods of decrypting files without paying the ransom fee which is approximately $500 


QUOTE: Like its predecessors, the new version is being distributed through drive-by download attacks that exploit vulnerabilities in outdated browser plug-ins or through other malware already installed on computers, researchers from Microsoft said Tuesday in a blog post.







How to Mount or Unmount ISO and IMG Files in Windows 10

An ISO or IMG file, also called a disc image, is a single file that’s a copy of an entire data CD or DVD.

When you mount an .ISO or .IMG file, it will be added as a CD/DVD drive in This PC.

This tutorial will show you how to natively mount or unmount ISO and IMG image files in Windows 10.

Read more…

Removal instructions for clicup

What is clicup?

The Malwarebytes research team has determined that clicup is adware. These adware applications display advertisements not originating from the sites you are browsing.


Getting the SQL for HQL and Criteria Queries

OK, so, I already showed how we can get the SQL that was generated from a LINQ query. Of course, we can do the same for both HQL and Criteria APIs as well (QueryOver is just a wrapper around Criteria, mind you).

So, for HQL (and SQL), it goes like this:

   1: public static class QueryExtensions

   2: {

   3:     private static readonly PropertyInfo sessionProperty = typeof (QueryImpl).GetProperty("Session", BindingFlags.NonPublic | BindingFlags.Instance);


   5:     public static String ToSql(this IQuery query)

   6:     {

   7:         if (query is QueryImpl)

   8:         {

   9:             var session = sessionProperty.GetValue(query, null) as ISession;

  10:             var sessionImpl = session.GetSessionImplementation();

  11:             var translatorFactory = new ASTQueryTranslatorFactory();

  12:             var translators = translatorFactory.CreateQueryTranslators(query.QueryString, null, false, sessionImpl.EnabledFilters, sessionImpl.Factory);


  14:             return translators[0].SQLString;

  15:         }

  16:         else if (query is SqlQueryImpl)

  17:         {

  18:             return (query.QueryString);

  19:         }


  21:         throw (new NotSupportedException("Query type is not supported."));

  22:     }

  23: }

You can pass any implementation if IQuery, such as one produced from ISession.CreateQuery() or ISession.CreateSQLQuery(). The static field is merely for performance reasons.

As for Criteria:

   1: public static class CriteriaExtensions

   2: {

   3:     public static String ToSql(this ICriteria criteria)

   4:     {

   5:         var criteriaImpl = criteria as CriteriaImpl;

   6:         var sessionImpl = criteriaImpl.Session;

   7:         var factory = sessionImpl.Factory;

   8:         var implementors = factory.GetImplementors(criteriaImpl.EntityOrClassName);

   9:         var loader = new CriteriaLoader(factory.GetEntityPersister(implementors[0]) as IOuterJoinLoadable, factory, criteriaImpl, implementors[0], sessionImpl.EnabledFilters);


  11:         return loader.SqlString.ToString();

  12:     }

  13: }

And finally, QueryOver, just a small wrapper around the Criteria version:

   1: public static class QueryOverExtensions

   2: {

   3:     public static String ToSql(this IQueryOver queryOver)

   4:     {

   5:         var criteria = queryOver.UnderlyingCriteria;

   6:         return (criteria.ToSql());

   7:     }

   8: }

Hope you find this useful! Winking smile

How to Change User Account Control (UAC) Settings in Windows 10

User Account Control (UAC) notifies you before changes are made to your PC that require administrator-level permission. This helps prevent potentially harmful programs from making changes to your computer. By default, UAC is set to notify you whenever apps try to make changes to your PC, but you can change how often UAC notifies you.

This tutorial will show you how to change User Account Control (UAC) settings for when to be notified about changes to your computer in Windows 10.

Read more…

Aktuelle OS und Firmware Versionen für Windows Phone

Auf der folgenden Microsoft Seite findet ihr die jeweils aktuellen Versionsnummern vom Operating System und der Hardware-Firmware für alle Nokia/Microsoft Lumia-Modelle.

Diese Tabelle gilt nicht für Entwickler, die am Developer Preview Program teilnehmen, da sie ja Beta-Versionen neuerer Releases verwenden. Aber ihr solltet in der Minderheit meiner Leser sein ;)


Viele Grüße

Dieter Rauscher
MVP Enterprise Security

Weekend reading

How to Turn On or Off Windows Defender in Windows 10

Windows Defender helps protect your PC against malware (malicious software) like viruses, spyware, and other potentially unwanted software. Malware can infect your PC without your knowledge: it might install itself from an email message, when you connect to the Internet, or when you install certain apps using a USB flash drive, CD, DVD, or other removable media. Some malware can also be programmed to run at unexpected times, not only when it’s installed.

You must be signed in as an administrator to be able to turn on or off Windows Defender.

Read more…

PowerShell Summit NA 2015 Agenda changes

We’ve had to make some minor changes to the Summit agenda – the revised schedule is shown on the event web site – http://eventmgr.azurewebsites.net/event/home/PSNA15

PowerShell Heroes 2015

Powershell.org has announced the 2015 list of PowerShell Heroes- http://powershell.org/wp/2015/01/17/announcing-our-2015-powershell-heroes/


These are people who have made an outstanding contribution to the PowerShell community but have not been recognised in other ways (such as an MVP award)


Please join me in congratulating them

Recent Comments