Check out my new iPhone app called LDS Memory: Scripture Mastery (SM)
Yes, it’s in the app store now! For more information, check out my website: www.scripturemasteryapp.com.
Yes, it’s in the app store now! For more information, check out my website: www.scripturemasteryapp.com.
Simply using Interface Builder, I could not find a way to make my buttons center multiple lines of text. If there is a super easy way, then let me know and I’ll update this post (but I don’t currently think there is). So I figured out how to do it programmatically, which is what I’m showing here in this post.
Go ahead and create your button using Interface Builder (or programmatically). If you use Interface Builder, then make sure you create the IBOutlets in the header file and appropriately link those attributes to the UIButtons in Interface Builder.
Once you’ve got the buttons created and linked, you’re ready to set the text for the button labels. To center the text you’ll need to use:
myCustomButton.titleLabel.textAlignment = UITextAlignmentCenter;
And to set the text so that it appears in two lines you’ll need to use:
[myCustomButton setTitle:@"theTopTextnBottomText" forState:UIControlStateNormal];
“myCustomButton” would be replaced by whatever name you’ve given your UIButton. Obviously you can use dot syntax or [brackets] for either line.
Notice that the “n” is used as a line break so that your button label will read “the Top Text” on the top and “Bottom Text” below it. Both will be centered as a result of you setting the text alignment.
Here is a snippet of my code and the resulting buttons:


Real quick post- if you run static analyzer, Clang, etc and it’s giving you this issue, it’s an easy fix. The error references the documentation that you can look at: “Creating and Returning NSError Objects” -see section 3-5.
This is what the error will look like:
![]()
This is how you fix it:

Pretty simple just put an if statement around it to make sure error isn’t null already!
Just saw this:
http://github.com/yllan/scifihifi-iphone/commit/9816a98f674b2933588e0447a9148ecd626882eb (unfortunately it’s not incorporated yet into the Master)
Keychain is really a pain to use, and I didn’t want to spend the time to figure it all out, so I went looking for a framework that would do the dirty work for me. I found SFHFKeychainUtils and it has been super slick! In this tutorial, I’ll show you how to leverage SFHFKeychainUtils in order to save a username/password to keychain and also retrieve the password given the username. Just follow these simple steps:
1. Get SFHFKeychainUtils
I found it on GitHub at http://github.com/ldandersen/scifihifi-iphone/tree/master/security/ – just get the SFHFKeychainUtils.h and SFHFKeychainUtils.m files and add them to your project.
2. Import it
In the implementation file where you want to save or retrieve the password, be sure you import the SFHF Keychain Utils header file as shown below:
#import “LoginViewController.h”#import “SFHFKeychainUtils.h”@implementation LoginViewController
3. Save a Username/Password

Here you can see how simple it is to add the username/password to the iPhone’s keychain. The storeUsername:andPassword:forServiceName:updateExisting:error method will take care of all the work for us if we give it the correct parameters. I am getting the username and password from two UITextFields in the app called usernameField and passwordField, respectively. The Service Name can be anything you want, as long as you remember it as you’ll need to enter that same string value in order to retrieve the password (see step 4).
4. Retrieve the Password from Keychain

As you can see, it’s not any more difficult to retrieve the password from keychain using SFHFKeychainUtils. I specified my username “Gorgando” and the same service name we used before “myApp”. The password that corresponds to this username and service name in the keychain will be returned as an NSString.
So don’t be afraid to use the keychain! It is the most secure way to store passwords in an iPhone application. Both plists and the Settings.Bundle are very insecure ways to store passwords because the passwords are stored in plaintext, visible to anyone who accesses them. Let me know if you have any questions – good luck!
It is actually very simple to create a splash screen for your Excel workbook. Just follow the steps below:
1. Create the User Form
In Excel hit Alt-F11 to bring up the Visual Basic Editor. In the Project Explorer Window, right click on your project, select Insert > User Form. I recommend you rename the user form something like “SplashScreen” in the Properties box. Drag an Image control from the toolbox onto your user form. In the Properties, select the cell next to “Picture” and click on the button with the “…”. This will allow you to select your image. Resize the image and form to your heart’s content.
2. Set Up the Splash Screen
Right-click on your user form and select “View Code”. It should automatically create a sub routine that looks like this:
Private Sub SplashScreen_Click()End Sub
Change that code so that it looks like the following (or just add the following code below it):
Private Sub UserForm_Initialize()
Application.OnTime Now + TimeValue(“00:00:02″), “KillForm”
End Sub
[Brief explanation - this is the Initialize sub routine that is called whenever the user form opens. Application.OnTime means "Do what I tell you when I tell you to do it". The "Now + TimeValue("00:00:02")" is the when - basically do it right now plus 2 additional seconds, or "wait two seconds to do it". The "KillForm" just tells the form to disappear. To sum it up, this sub is just making the form disappear 2 seconds after it is launched.]
Feel free to change the duration that the splash screen stays visible by changing the 00:00:02 to something else.
3. Show the Splash Screen at Launch
In the Project Explorer Window (we’re still in the Visual Basic Editor), open the file called “ThisWorkbook”. It will most likely be empty if you have not previously added code here. Enter the following code, but change “SplashScreen” to be whatever you named your user form:
Private Sub Workbook_Open()
SplashScreen.Show
End Sub
[Brief explanation - this Workbook_Open sub will run every time the Excel workbook opens. Your user form name .Show just displays the user form, which will then trigger the Initialize sub that we set up in step 2.]
Make sure to save as a Macro-Enabled Workbook (xls or xlsm) and YOU’RE DONE!
Every time it’s opened, you’re splash screen should display for the amount of time you set. Let me know if you have any questions and good luck!
Since there is no native ability in Objective C in the Cocoa Framework to use REGEX (Regular Expressions), you need to use a framework. I found that RegexKitLite was the perfect solution for my app. You can use it in 3 simple steps:
1. Add the RegexKit Framework to your app’s project in XCode
You can download the source at http://regexkit.sourceforge.net/#Downloads. Then just add the RegexKitLite.h and RegexKitLite.m files to your project. Also, you’ll need to add the libicucore.dylib Framework to your project. This can be done by right clicking on the Frameworks folder in xCode, selecting Add > Add Existing Framework and then selecting to add libicucore.dylib. Be sure to import the RegexKitLite.h file wherever you plan to use it: #import “RegexKitLite.h”.
2. Create an NSString with the Regular Expression
For example I needed a regular expression that would find all the HTML tags in an NSString and get rid of them by replacing them with an empty string “”. It looks like this:
NSString *myregex = @”<[^>]*>”; //regex to remove any html tag
3. Use the StringByReplacingOccurencesOfRegex method to replace your NSString
I think the best way to explain this is to just show it:
NSString *description = @”<html><body><p>This is the description! </p></body></html>”;
description = [description stringByReplacingOccurrencesOfRegex:myregex withString:@""];
The final description variable will just say “This is the description! ” as the tags are stripped out. All you have to do is plug in your regex NSString variable from step 2 where I have “myregex” and plug in whatever string you want to replace it with where I have @”" (an empty string to delete the occurrence rather than replace it).
Hope this is helpful- good luck!
Using data validation is extremely simple and you don’t even have to use VBA to do it. I’m using Excel 2010, but the process is the same in 2007. I’ll show you how to set up the data validation and two ways to populate the list, dynamically and hard-coded.
With Hard-coded list values:
With Dynamic values:
![]()
I looked all over to find a way to do subqueries and “not in” statements using LINQ. This post is to share the simplest way that I’ve found.
Here is the SQL query that I was trying to recreate in LINQ:
SELECT DISTINCT lu.leagueid, lu.id, AS Expr1, l.nameFROM leagueuser AS lu INNER JOINleague AS l ON lu.leagueid = l.idWHERE (l.name NOT IN(SELECT league.nameFROM league INNER JOINleagueuser ON league.id = leagueuser.leagueidWHERE (leagueuser.userid = 4)))
Dim firstquery = From b In dc.leagueusers Where b.userid = currentUser Select b.leagueidDim leaguesnotjoined = From p In dc.leagueusers Where Not firstquery.Contains(p.leagueid) Select New With {p.league.id, p.league.name} Distinct
This was weird today. My iPhone app was crashing when I ran it, and it crashed for some other people (but not for everyone). This was right after a new JSON was being loaded by the application. So I got into xCode and ran it on my emulator. It worked fine. I hooked up xCode to my iPod Touch and ran the application to the iPod. Sure enough it was crashing like crazy. I spent 3 hours trying to fix a phantom memory problem. I still haven’t fixed it, but I learned one thing. Restart your device, and the problem is “solved”. I put that in quotes because I’m sure it will rear its ugly head again if not identified and fixed correctly, but that was a temporary fix that tells me it must be some kind of memory issue. I’ll post later (or comment) if I discover the true root of this.
So, I’ve been struggling through some of the basics of Android development over the past few days. Then on Monday, I found a goldmine. I stumbled across this blog: Sai Geetha’s Blog which walks you through 15 (and more coming) simple tutorials intended for Android beginners like me. Each tutorial has sample code you can download, run, and tweak.
She keeps her explanations succinct and clear. I’m now understanding more about Android development after a couple hours with his blog than the past couple weeks combined. So I figured she deserved a shout out. If you’re learning Android- Definitely check out those tutorials!
Here is a list of the different tutorials that Sai explains: