iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

How to determine if an NSString is latin based?

I’m trying to determine if a string is latin based or Japanese. I’ve tried something like the following but it returns YES for Japanese strings as well: NSCharacterSet *alphaSet = [NSCharacterSet alphanumericCharacterSet]; BOOL isAlpha = [[myStr stringByTrimmingCharactersInSet:alphaSet] isEqualToString:@””]; A string might be a word like “café” or something like “カフェ” or “喫茶店”.

how to dismiss action sheet

i used this code to show uipicker in uiactionsheet but when i click close button i want to remove action sheet from view. so what should be the code for removing actionSheet form view. – (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent]; CGRect pickerFrame = CGRectMake(0, 40, […]

Add ivars in @implementation

For good encapsulation, decent Objective-C programmers put their private ivars in a private extension declared in the main implementation file, like this: // MyClass.m @interface MyClass () { float value; } @end @implementation MyClass @end But recently, I found a simpler way to hide private ivars: ivars can be declared in a {} block following […]

why is textFieldDidEndEditing: not being called?

I’m playing with writing my first iphone app; SDK 3.0. I’ve got a UITextField, and when text gets entered into that, I want to obtain the doubleValue from the text field and perform some computations and display them in a UITableView. The delegate for the UITextField adopts the UITextFieldDelegate protocol, and implements both textFieldShouldReturn: and […]

Core Data: Keypath “objectID” not found in entity

I’m using NSFetchedResultsController with a predicate to load a list of Documents in my application. I want to load all the Documents except the currently active one. I am using Rentzsch’s MOGenerator to create a _Document class and then I put all my custom code in the Document subclass. _Document generates an objectID property with […]

NSTextField placeholder text doesn't show unless editing

I set the placeholder text of my NSTextField in Interface Builder, but the placeholder text doesn’t show until I click inside the text field to edit it. Anyone else having this issue? Thanks EDIT: Screenshots. Here’s what the field looks like when I’m not editing it: Not editing And this is what it looks […]

Objective C – Sort an array of string

I have to sort an array of objects by a property of the objects that is a string. How can I do this?

Why is the row property of NSIndexPath a signed integer?

Why is the row property of NSIndexPath a signed integer? Could it ever take on a “valid” negative value? edit I haven’t thought about this until today when I set LLVM to check sign comparison. This made the compiler spew out warnings whenever there was indexPath.row <= [someArray count] or similar.

Automatic Reference Counting (ARC) says that invoking is forbidden…what is the alternative?

I’m starting to use iOS5 and I’ve enabled ARC for my project. I have a class where on deallocation I save the state of that object. -(void)dealloc { [self save]; [super dealloc]; } However, under ARC, [super dealloc] is not allowed? I thought that it was considered a bug if you don’t invoke the dealloc […]

Objective-C (cocoa) equivalent to python's endswith/beginswith

Python has string.startswith() and string.endswith() functions which are pretty useful. What NSString methods can I use to have the same function?