UISearchBar to be the top item in the view

January 22nd, 2009

Picture 1.png

So what to do if you’re building a view and you have a navigationBar at the top of the view but you want a searchbar at the top instead?

Try this in your viewDidLoad:

 self.navigationController.navigationBar.topItem.titleView = searchBar;

Of course you’ll need to define searchBar in the header file too…

IBOutlet UISearchBar *searchbar;

Along with doing all the NIB file stuff, property declarations, blah blah blah… but you get the idea.

brandon Coding

Link for me to watch the inauguration

January 19th, 2009

Had to write a VBScript today

January 13th, 2009

003_p5_det_c
Creative Commons License photo credit: wisof

Had to write a VBScript today to do some funky stuff. Basically we needed to copy in a string of text and then output that text so it would be formatted to go into an email.

Input text looked something like:

x.x.x.0/x Company  How Assigned    Location

The big issue I had with all of this is that there’s spaces in the company names, spaces in the location, spaces in how assigned… so I couldn’t use a space as the delimter. Well, the code is UGLY… but the general concept is I knew I had certain points where I would have more than one space in a row. After the company name I had 2 spaces. After the How assigned I had 4 spaces. So I could create a couple arrays and delimit using those known values. The only other problem I had was how to get rid of the IP address before the company name… well I solved that by getting rid of all the numbers from the section of the array where the company should be. Again this isn’t pretty – but it got the job done.

window.resizeTo 450,500

dim arrHeaders(3), strIP, strCompany, strStatus, strNewContent
arrHeaders(0) = "IP Block:"
arrHeaders(1) = "Customer:"
arrHeaders(2) = "Status:"
arrHeaders(3) = "IDC:"

Sub SetCopyPaste

strPortal = "From the site:"

strline = CopyPaste.value
arrFields = Split(strLine)
arrFields2 = Split(strline, "  ")
cutString = arrFields2(0)
arrFields3 = Split(strline, "    ")

strAlphaNumeric = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
For i = 1 to len(cutString)
strChar = mid(cutString,i,1)
If instr(strAlphaNumeric,strChar) Then
CleanedString = CleanedString & strChar
End If
next

strIP = arrFields(0)
strCompany = CleanedString
strStatus = arrFields2(1)
strIDC = arrFields3(1)
strNewContent = strPortal & vbCrLf & vbCrLf & arrheaders(0) & " " & strIP & " - " & strStatus & vbCrLf _
& arrHeaders(1) & " " & strCompany & vbCrLf & arrheaders(3) & " " & strIDC

CombinedText.Value = strNewContent

End Sub

Obviously there’s VBSCRIPT tags at the top and the bottom… and some HTML to format the page.

The attached file you can grab and see the whole thing with the code and whatnot.

Output text looked like this:
From the site:

IP Block: x.x.x.0/x – How Assigned
Customer: Company
IDC: Location

spam-email

brandon Coding

Windows 7 Beta Keys

January 11th, 2009

Windows 7 Betta Fish
Creative Commons License photo credit: nxtiak

So apparently there are only a certain set of known keys for the Windows 7 Beta – which so far I’ve been able to confirm that these are the only ones being generated. Rather than have you waste a bunch of time trying to get a “special” key that’s just for you – here they are:

There are 14 known keys for windows 7 and here they are:
32bit
QXV7B-K78W2-QGPR6-9FWH9-KGMM7
TQ32R-WFBDM-GFHD2-QGVMH-3P9GC
6JKV2-QPB8H-RQ893-FW7TM-PBJ73
4HJRK-X6Q28-HWRFY-WDYHJ-K8HDH
GG4MQ-MGK72-HVXFW-KHCRF-KW6KY

64bit
RFFTV-J6K7W-MHBQJ-XYMMJ-Q8DCH
482XP-6J9WR-4JXT3-VBPP6-FQF4M
7XRCQ-RPY28-YY9P8-R6HD8-84GH3
D9RHV-JG8XC-C77H2-3YF6D-RYRJ9
JYDV8-H8VXG-74RPT-6BJPB-X42V4

And just in case you need the 32Bit ISO

brandon General

TabBarViewController with TableViews

January 10th, 2009

Coding can kill
Creative Commons License photo credit: databhi ♪♫

Here’s the solution to that generic problem of creating a tabBarController that has Navigation Controllers / tableViews under each tab.

(SOURCE LINK – See posts 5 & 8 )

Here's the code. Reposted for my future reference in case the source disappears. 

@interface AppDelegate : NSObject  {
    UIWindow *window;
    UITabBarController *tabBarController;
    MyTableViewController *myTableViewController;
    MySecondTableViewController *mySecondTableViewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UITabBarController *tabBarController;
@property (nonatomic, retain) MyTableViewController *myTableViewController;
@property (nonatomic, retain) MySecondTableViewController *mySecondTableViewController;

@end

@implementation AppDelegate

@synthesize window, myTableViewController, mySecondTableViewController, tabBarController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {

       tabBarController = [[UITabBarController alloc] init];          // creates your tab bar so you can add everything else to it

       myTableViewController = [[MyTableViewController alloc] init];               // creates your table view - this should be a UIViewController with a table view in it, or UITableViewController
       UINavigationController *tableNavController = [[[UINavigationController alloc] initWithRootViewController:myTableViewController] autorelease];
       [myTableViewController release];                                                              // creates your table view's navigation controller, then adds the view controller you made. Note I then let go of the view controller as the navigation controller now holds onto it for me. This saves memory.

       mySecondTableViewController = [[MySecondTableViewController alloc] init];
       UINavigationController *table2NavController = [[[UINavigationController alloc] initWithRootViewController:mySecondTableViewController] autorelease];
       [mySecondTableViewController release];                                                    // does exactly the same as the first round, but for your second tab at the bottom of the bar.

       tabBarController.viewControllers = [NSArray arrayWithObjects:tableNavController, table2NavController, nil]; add both of your navigation controllers to the tab bar. You can put as many controllers on as you like, but they will turn into the more button like in the iPod program.

       [window addSubview:tabBarController.view];                                              // adds the tab bar's view property to the window
       [window makeKeyAndVisible];                                                                  // makes the window visible
}

- (void)dealloc {
       [tabBarController release];
       [window release];
       [super dealloc];
}                                           // lets go of everything else, thats so your program doesn't create any leaks of memory.

@end

brandon Coding

AppDelegate –

January 10th, 2009

2007-06-11-14-57-24
Creative Commons License photo credit: sonicwalker

So, for the past few days I’ve been pulling my hair out (because I’m not a programmer so this is all new to me). I was having a really hard time with figuring out why even if I had a class named AppDelegate, and I had all the methods I needed in that AppDelegate class I would get exceptions thrown at runtime because I was requesting something my tableview controller that it didn’t have. Drove me bananas trying to figure out why the tableview controller was responding and throwing errors when I knew the AppDelegate class has the right stuff.

Turns out there was one little problem with my understanding of the Model-View-Controller concept – and its this:

You can have as many classes as you want, and you can call them all kinds of things including AppDelegate, but only one of them is actually going to be the app delegate – and it’s the one that has this little line in it:

@interface AppDelegate : NSObject <UIApplicationDelegate> {

// notice the part where it conforms to UIApplicationDelegate. That’s the key!

I gleaned this little jem of information in an explanation from (another) Brandon here:

The AppDelegate is basically your application’s controller. It is where execution begins (other than main.m). That line was put into place to access the AppDelegate object. This was to get a reference to the “fruits” array. The “fruits” array was declared inside of our application’s delegate.
Here it is line by line

FruitAppDelegate *appDelegate

// Declaring an object to hold the reference to the applicaiton’s appDelegate

(FruitAppDelegate *)

// We are casting the return value of the next phrase to a FruitAppDelegate

[[UIApplication sharedApplication] delegate]

// This gives us a reference to the appDelegate for the whole application

now that the appDelegate object holds a reference to the application’s appDelegate object, we can access variables that are declared inside of it. This allows us to do things like [appDelegate.fruits count] which will return the number of fruits in the array.
I hope that helps…

So they key to all of this – is AppDelegate isn’t that class you smartly named AppDelegate. The AppDelegate was defined when you started the project.

brandon Coding

New element discovered

January 7th, 2009

Capitol at Sunset
Creative Commons License photo credit: vgm8383

Lawrence Livermore Laboratories has discovered the heaviest element yet known to science. The new element, Governmentium (symbol=Gv),has one neutron, 25 assistant neutrons, 88 deputy neutrons, and 198 assistant deputy neutrons, giving it an atomic mass of 312.

These 312 particles are held together by forces called morons, which are surrounded by vast quantities of lepton-like particles called peons.

Since Governmentium has no electrons, it is inert. However, it can be detected, because it impedes every reaction with which it comes into contact. A tiny amount of Governmentium can cause a reaction that would normally take less than a second, to take from 4 days to 4 years to complete.

Governmentium has a normal half-life of 2 to 6 years. It does not decay, but instead undergoes a reorganization in which a portion of the assistant neutrons and deputy neutrons exchange places. In fact, Governmentium’s mass will actually increase over time, since each reorganization will cause more morons to become neutrons, forming isodopes.

This characteristic of moron promotion leads some scientists to believe that Governmentium is formed whenever morons reach a critical concentration. This hypothetical quantity is referred to as critical morass.

When catalyzed with money, Governmentium becomes Administratium (symbol=Ad), an element that radiates just as much energy as Governmentium, since it has half as many peons but twice as many morons.”

(via email)

Mike Snodgrass

Denver Hardwood

brandon General

Fail Times Two

January 5th, 2009

While I hope the people are ok … and I’m sure they are, one quality fail deserves another!

(via FailBlog)

brandon General

I miss birthdays like this

January 4th, 2009

image787646570.jpgThis is a picture we took of my daughter – she was dying to open her birthday presents at dinner the other night. I miss being this excited for my presents…

brandon General

Quick Note: Don’t pay for iPhone unlocking

January 4th, 2009

iphone3g_jailbreak_8oct2008_3327
Creative Commons License photo credit: patrick h. lauke

Quick note to anyone who doesn’t know yet… This:

Hi

I can unlock all iPhones. All 1-st, 2-nd and 3G’s!!! I use software unlock only. Newest firmware 2.2. with cydia and installer.

I have unlocked over 17 3G’s in the past 3 days and they all work perfect for t-mobile and other carrier. I have unlocked my own 3G and Its working smooth as butter with my t-mobile sim. I’m a professional at what I do and I do it the right way. You can wait in my house while I unlock your iPhone. Call me if interested. After I unlock your iPhone you can always call me if you have any questions I’ll be glad to help.

Is bullshit. DO NOT PAY someone $25 or more to unlock your iPhone v1 or 3G. They are just using the same software you can get for free from: the iPhone Dev Team

Via Craigslist (PS. Please do not call this guy…)

brandon iPhone

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.