iphone Programming Glossary: rng
Generate non-repeating, no sequential numbers http://stackoverflow.com/questions/2612784/generate-non-repeating-no-sequential-numbers modern variant of the Fisher Yates shuffle . For example in C# public static void Shuffle T IList T collection Random rng for int i collection.Count 1 i 0 i int randomIndex rng.Next i 1 T tmp collection i collection i collection randomIndex.. in C# public static void Shuffle T IList T collection Random rng for int i collection.Count 1 i 0 i int randomIndex rng.Next i 1 T tmp collection i collection i collection randomIndex collection randomIndex tmp If you want to produce more.. like this again C# but should be easy to port HashSet int numbers new HashSet int while numbers.Count 15 numbers.Add rng.Next List int list numbers.ToList Now shuffle as before The shuffling at the end is to make sure that any ordering which..
Change the UITextView Text Direction http://stackoverflow.com/questions/4905500/change-the-uitextview-text-direction initWithFrame CGRectMake 0 20 320 480 self.view v v release void setText NSString txt NSString result nil NSRange rng NSArray words txt componentsSeparatedByString @ we should do it iteratively cause it's the simplest way for NSString word.. 1 r.location i result ReverseTextVC reverseText word substringWithRange r withFont _tv.font carretPosition rng Lines _lines Bounds _tv.bounds _tv.text result #pragma mark #pragma mark UITextViewDelegate BOOL textView UITextView.. BOOL textView UITextView textView shouldChangeTextInRange NSRange range replacementText NSString text NSRange rng textView.text ReverseTextVC reverseText text withFont textView.font carretPosition rng Lines _lines Bounds textView.bounds..
iPhone - Comparing strings with a German umlaut http://stackoverflow.com/questions/7656938/iphone-comparing-strings-with-a-german-umlaut marks. For example ˜Ã¶â€ is equal to ˜o For example NSString text @ gënder NSString searchString @ ender NSRange rng text rangeOfString searchString options NSDiacriticInsensitiveSearch if rng.location NSNotFound NSLog @ Match at @ NSStringFromRange..
|