Xcode 4 – clang error

Apparently, you’ve set custom compiler flags for the include paths. Go to your target’s build settings and check this option: Other C flags If you have something in it, you may replace it by the -iquote version. Otherwise, still in the build settings, check the value of the following options: Header Search Paths User Header … Read more

Password validation in UITextField in iOS

This is how I would do it. The validation should be done at the end when the user has typed in the password and not in between.I will not be using NSRegularExpression. -(void)textFieldDidEndEditing:(UITextField *)textField{ int numberofCharacters = 0; BOOL lowerCaseLetter,upperCaseLetter,digit,specialCharacter = 0; if([textField.text length] >= 10) { for (int i = 0; i < [textfield.text … Read more

Run AppleScript from Cocoa Application

Solved! Xcode wasn’t saving my script file into app’s resources path. To run an AppleScript code from Cocoa Application, use this: NSString *path = [[NSBundle mainBundle] pathForResource:@”ScriptName” ofType:@”scpt”]; NSURL *url = [NSURL fileURLWithPath:path];NSDictionary *errors = [NSDictionary dictionary]; NSAppleScript *appleScript = [[NSAppleScript alloc] initWithContentsOfURL:url error:&errors]; [appleScript executeAndReturnError:nil]; Swift 5.6.1: import AppleScriptObjC import Cocoa let path = … Read more

Listen to a value change of my text field

You can set a delegate for your NSTextField instance and have the delegate implement the following method: – (void)controlTextDidChange:(NSNotification *)notification { // there was a text change in some control } Your delegate object can be the application delegate, a window controller, a view controller, or some other object in your application. The delegate can … Read more

How do I do weak linking in Swift?

Seems like I’ve figured out what you can do I used NSClassFromString() to check if class is available on device, i.e. if NSClassFromString(“UIBlurEffect”) { let blur = UIBlurEffect(…) //… } else { //… } It’s needed to make UIKit.framework (or another corresponding framework) optional. If you create Swift-based application in XCode6-BetaX, all the frameworks wouldn’t … Read more