Home OFC Tech (blog)

OFC Tech (Strategy & Technology Blog)

C# equivalents in Objective C

E-mail Print

Okay, so I've got a free moment, and I've decided to bless the interwebs with a little bit of my wisdom.  Basically I'm going to use this post as a little bit of a living document to highlight the Objective C equivalents of some basic and not so basic C# statements. I'll start out with the super easy stuff for those extra challenged programmers out there.

 

Basic String Concatenation
C# Objective C
string headerDescription;
string header = "We makin apps ";
string description = "up in here";

headerDescription = header + description;

lblHeader.text = headerDescription

NSString *headerText = @"Yea... all kind of apps being developed";
NSString *description = @". in Obj C";
NSMutableString *headerDescription = [NSMutableString string];

 

// Concatenate strings
[headerDescription appendString:headerText];
[headerDescription appendString:description];

 

 

lblHeader.text = headerDescription;
Add a comment
Last Updated ( Wednesday, 03 October 2012 03:19 )
 

SQL Server Country Table

E-mail Print

The problem:

I needed a (SQL Server) table containing a list of countries to use in addresses, dropdown lists, etc.

 

The Resolution:

I found a few CSV files and so forth online with country data, but none of them were formatted for the "super lazy" developer.  So I'm sharing the script I wound up using in the hopes that it will save a few minutes of someone's time out there.

The script file is here: CountriesTableLoad.sql.txt.  It creates the table schema and loads the data.  All you have to do is drop it into management studio and hit F5.

 

Country Table Result

 

 

Add a comment
Last Updated ( Sunday, 20 May 2012 23:27 )
 

Configure Log4Net with NUnit

E-mail Print
The Problem:

When you use the NUnit grapical interface to run unit tests, it short circuits the output from log4net.  This happens because NUnit itself is using log4net, and by default it turns the log outputs off.  The end result of this is that you go through all this trouble to get log4net working correctly, and your log entries mysteriously fail to show up when you run the unit tests.  This affect both console logging, and logging to files.

 

The resolution:

There is definitely some information out there, but most of what I found was a touch cryptic.  The purpose of this entry is share a plain English way of working around this problem.

 

Step 1: Add an application config file and rename it to something like "Test.config".  Don't be hard headed like me and ask "Why do I need to rename this file".  Just do it and make sure that the config file you add has the appropriate build action set so it gets copied to the bin directory as content.

Nunit_testconfig

 

Step 2: Add your log4net configuration entry to the "Test.config" file.  If you're reading this article, you should already know how to do this.  But if you don't, please refer to the log4net setup documentation.

 

Step 3: Add code to your unit test project to configure log4net at runtime (i.e. after the NUnit GUI has messed with the configuration).  The code snippet below does it in the constructor of one of my test classes.  This has the obviously limitation of only firing our configuration code once a test in this particular class is fired.  Optional: If you want a more global version of this approach that applies to all of your tests classes, embed the runtime log4net configuration in a class marked as being a [SetupFixture] instead of placing in an actual test class.

 

[TestFixture]
public class LoggingTests
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

public LoggingTests()
{
FileInfo fileInfo = new FileInfo(@"C:\MOHQ\Middleware\UnitTests\bin\Debug\Test.config");
log4net.Config.XmlConfigurator.Configure(fileInfo);
}

[Test]
public void BasicLogTest()
{
log.Error("Hmm, Write my log entry already");
}

[Test]
public void DatabaseLogTest()
{

}
}

 

At this point your done.  Any log4net entries you have configured should now show up in the appropriate logs.

Add a comment
Last Updated ( Monday, 05 April 2010 14:55 )
 

WPF Shader Effects - Part I

E-mail Print

This article is kind of "Shader Effects for Dummies".  Or maybe more appropriately, "Shader Effects for people who don't really know **** about WPF".  So with that out of the way, here goes...

I got started by watching this video on YouTube that shows off a ton of custom transition effects for WPF.  If you'd like to incorporate some of these effects into one of your own WPF applications, there are a few gotchas that you are expected to figure out on your own.


  • Gotcha 1: You have to download the effect library source from Codeplex and compile the binaries yourself.  The source can be found here.
  • Gotcha 1a: The source on Codeplex won't compile cleanly. I had to make a code fix to line 38 of the Ripple.fx file in the effects library.  I changed: float falloff = saturate(1-distance); to: float falloff = 1-distance; per the screenshot below.

    Ripple
  • Gotcha 2: Once you add refererences to the shader effect libraries to your project, you have a whole new set of effects that you can choose from in Expression Blend.

    Effects

  • Gotcha 3: You really *really* should get comfortable with creating animations and using the built in render transform functionality in Expression Blend before trying to tackle your own programatic implementation of the Shader Effects library for the first time.  This is just my opinion, but once you see the XAML getting output as you add things to the Blend timeline, its much easier to concepualize your own implementation.  This video on YouTube is a provides a pretty clear explanation of what render trasformations do for you with WPF.

 


Stay tuned for part 2 of this series where I run through a couple examples of how to implement simple transitions programmatically.

Add a comment
Last Updated ( Friday, 19 March 2010 02:41 )
 

Install SmarterStats on IIS7

E-mail Print

The Problem:

After completing the installation of SmarterStats (A web analytics package from SmarterTools Inc.) on Windows Server 2008 / IIS7, you are unable to login in when accessing the site through the IIS7.  Attempting to log in with the correct credentials results in an error message indicating that the site/user/pass is invalid.  This problem persists even though you follow the supplied installation instructions to the letter.

SmarterStats

In my case I was able to log in perfectly fine when I accessed the site via SmarterStats built in web service, but not when I attempted the host the site through IIS.  The other thing that really threw me is the fact that I had done this installation over a dozen times on IIS6/Win2k3 without any sort of hitch whatsoever.

The Resolution:

SmarterStats needs to be able to write it's configuration data at: "C:\Program Files\SmarterTools\SmarterStats\MRS\App_Data".  On Windows Server 2003, this just works, no tweaking required.  On Windows Server 2008, attempted writes to this path fail unless you take some specific actions. (They exacerbate the problem by masking the exception that gets generated and making it look like an invalid credential)

What causes this is a key difference between IIS6 application pools and IIS7 application pools (on a Windows 2008 server).  In IIS6, app pools have a default identity of "Network Service".  On Windows 2008 they have a default identity of "ApplicationPoolIdentity".  The fix is to manually change the identity of the application pool that SmarterStats is running in to "Network Service", and give "Network Service" modify permissions on the App_Data folder. Once you've done that you should be able to log in normally.

Add a comment
Last Updated ( Saturday, 13 March 2010 15:29 )
 
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  Next 
  •  End 
  • »
Page 1 of 2

ID Card Printing

WorkForce ID cards are custom designed to reflect you unique business, brand or identity. Click to view our product brochure

WorkForceID_Marketing_v1.11

We also have specific offerings tailored to small businesses and individual entrepreneurs.


Certifications

Oracle Partner Logo

MS Partner Logo

Our Partners

The Gravely Group
INCREASE CDC
ECDI - Columbus
DMW Computers

Our Products

Sample imageNeighborhood Shield Drive
WorkForce ID
My Property Tag

Our Services

Application Development
Website Design
Flash Multimedia Design
Ecommerce & Storefronts
Card Printing & Plastics