Abizer Nasir avatar Abizer Nasir committed f040cb5

Initial project

Comments (0)

Files changed (6)

+# Charsets
+
+A very basic example that shows how to validate string input with NSCharacterSet

charsets.xcodeproj/project.pbxproj

+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 46;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		AD0839AE16C6634C006C79AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD0839AD16C6634C006C79AA /* Foundation.framework */; };
+		AD0839B116C6634C006C79AA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AD0839B016C6634C006C79AA /* main.m */; };
+		AD0839BD16C667B2006C79AA /* Validator.m in Sources */ = {isa = PBXBuildFile; fileRef = AD0839BC16C667B2006C79AA /* Validator.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+		AD0839A816C6634C006C79AA /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+		AD0839AA16C6634C006C79AA /* charsets */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = charsets; sourceTree = BUILT_PRODUCTS_DIR; };
+		AD0839AD16C6634C006C79AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+		AD0839B016C6634C006C79AA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+		AD0839B316C6634C006C79AA /* charsets-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "charsets-Prefix.pch"; sourceTree = "<group>"; };
+		AD0839BB16C667B2006C79AA /* Validator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Validator.h; sourceTree = "<group>"; };
+		AD0839BC16C667B2006C79AA /* Validator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Validator.m; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		AD0839A716C6634C006C79AA /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				AD0839AE16C6634C006C79AA /* Foundation.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		AD0839A116C6634C006C79AA = {
+			isa = PBXGroup;
+			children = (
+				AD0839AF16C6634C006C79AA /* charsets */,
+				AD0839AC16C6634C006C79AA /* Frameworks */,
+				AD0839AB16C6634C006C79AA /* Products */,
+			);
+			sourceTree = "<group>";
+		};
+		AD0839AB16C6634C006C79AA /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				AD0839AA16C6634C006C79AA /* charsets */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		AD0839AC16C6634C006C79AA /* Frameworks */ = {
+			isa = PBXGroup;
+			children = (
+				AD0839AD16C6634C006C79AA /* Foundation.framework */,
+			);
+			name = Frameworks;
+			sourceTree = "<group>";
+		};
+		AD0839AF16C6634C006C79AA /* charsets */ = {
+			isa = PBXGroup;
+			children = (
+				AD0839B016C6634C006C79AA /* main.m */,
+				AD0839B216C6634C006C79AA /* Supporting Files */,
+				AD0839BB16C667B2006C79AA /* Validator.h */,
+				AD0839BC16C667B2006C79AA /* Validator.m */,
+			);
+			path = charsets;
+			sourceTree = "<group>";
+		};
+		AD0839B216C6634C006C79AA /* Supporting Files */ = {
+			isa = PBXGroup;
+			children = (
+				AD0839B316C6634C006C79AA /* charsets-Prefix.pch */,
+			);
+			name = "Supporting Files";
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		AD0839A916C6634C006C79AA /* charsets */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = AD0839B816C6634C006C79AA /* Build configuration list for PBXNativeTarget "charsets" */;
+			buildPhases = (
+				AD0839A616C6634C006C79AA /* Sources */,
+				AD0839A716C6634C006C79AA /* Frameworks */,
+				AD0839A816C6634C006C79AA /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = charsets;
+			productName = charsets;
+			productReference = AD0839AA16C6634C006C79AA /* charsets */;
+			productType = "com.apple.product-type.tool";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		AD0839A216C6634C006C79AA /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+				LastUpgradeCheck = 0460;
+				ORGANIZATIONNAME = "Jungle Candy Software";
+			};
+			buildConfigurationList = AD0839A516C6634C006C79AA /* Build configuration list for PBXProject "charsets" */;
+			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
+			hasScannedForEncodings = 0;
+			knownRegions = (
+				en,
+			);
+			mainGroup = AD0839A116C6634C006C79AA;
+			productRefGroup = AD0839AB16C6634C006C79AA /* Products */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				AD0839A916C6634C006C79AA /* charsets */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+		AD0839A616C6634C006C79AA /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				AD0839B116C6634C006C79AA /* main.m in Sources */,
+				AD0839BD16C667B2006C79AA /* Validator.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+		AD0839B616C6634C006C79AA /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.8;
+				ONLY_ACTIVE_ARCH = YES;
+				SDKROOT = macosx;
+			};
+			name = Debug;
+		};
+		AD0839B716C6634C006C79AA /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.8;
+				SDKROOT = macosx;
+			};
+			name = Release;
+		};
+		AD0839B916C6634C006C79AA /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "charsets/charsets-Prefix.pch";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		AD0839BA16C6634C006C79AA /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "charsets/charsets-Prefix.pch";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		AD0839A516C6634C006C79AA /* Build configuration list for PBXProject "charsets" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				AD0839B616C6634C006C79AA /* Debug */,
+				AD0839B716C6634C006C79AA /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		AD0839B816C6634C006C79AA /* Build configuration list for PBXNativeTarget "charsets" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				AD0839B916C6634C006C79AA /* Debug */,
+				AD0839BA16C6634C006C79AA /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = AD0839A216C6634C006C79AA /* Project object */;
+}

charsets/Validator.h

+//
+//  Validator.h
+//  charsets
+//
+//  Created by Abizer Nasir on 09/02/2013.
+//  Copyright (c) 2013 Jungle Candy Software. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface Validator : NSObject
+
++ (BOOL)isValidString:(NSString *)string;
+
+@end

charsets/Validator.m

+//
+//  Validator.m
+//  charsets
+//
+//  Created by Abizer Nasir on 09/02/2013.
+//  Copyright (c) 2013 Jungle Candy Software. All rights reserved.
+//
+
+#import "Validator.h"
+
+@implementation Validator
+
++ (BOOL)isValidString:(NSString *)string {
+    static NSCharacterSet *unwantedCharacters = nil;
+    if (!unwantedCharacters) {
+        unwantedCharacters = [[NSCharacterSet alphanumericCharacterSet] invertedSet];
+    }
+
+    NSRange rangeOfUnwantedCharacters = [string rangeOfCharacterFromSet:unwantedCharacters];
+
+    if (rangeOfUnwantedCharacters.location == NSNotFound) {
+        return YES;
+    } else {
+        return NO;
+    }
+}
+
+@end

charsets/charsets-Prefix.pch

+//
+// Prefix header for all source files of the 'charsets' target in the 'charsets' project
+//
+
+#ifdef __OBJC__
+    #import <Foundation/Foundation.h>
+#endif
+//
+//  main.m
+//  charsets
+//
+//  Created by Abizer Nasir on 09/02/2013.
+//  Copyright (c) 2013 Jungle Candy Software. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "Validator.h"
+
+int main(int argc, const char * argv[]) {
+    @autoreleasepool {
+        NSString *goodString = @"abcdefghijklmnopqrstuvwxyz0123456789";
+        NSString *badString = @"[this & this are wrong]";
+
+        NSLog(@"Good String is valid: %@", [Validator isValidString:goodString] ? @"YES" : @"NO");
+        NSLog(@"Bad String is valid: %@", [Validator isValidString:badString] ? @"YES" : @"NO");
+        
+    }
+    return 0;
+}
+
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.