Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 21st, 2012  |  syntax: None  |  size: 1.67 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //
  2. //  sddsfAppDelegate.m
  3. //  sddsf
  4. //
  5. //  Created by Iffat Razzaq on 12/21/11.
  6. //  Copyright 2011 nUCROSOFT. All rights reserved.
  7. //
  8.  
  9. #import "sddsfAppDelegate.h"
  10.  
  11. @implementation sddsfAppDelegate
  12.  
  13. @synthesize window = _window;
  14.  
  15. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  16. {
  17.     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  18.     // Override point for customization after application launch.
  19.     self.window.backgroundColor = [UIColor whiteColor];
  20.     [self.window makeKeyAndVisible];
  21.    
  22.    
  23.    
  24.     NSArray *arr = [NSArray arrayWithObjects:[NSNumber numberWithInt:4],
  25.                     [NSNumber numberWithInt:3],
  26.                     [NSNumber numberWithInt:5],
  27.                     [NSNumber numberWithInt:1],
  28.                     [NSNumber numberWithInt:4],
  29.                     [NSNumber numberWithInt:5],nil];
  30.    
  31.    
  32.     int result = [self findLastInArray:arr occurance:4];
  33.    
  34.     return YES;
  35. }
  36.  
  37. - (NSInteger)findLastInArray:(NSArray *)arr occurance:(NSInteger)ocr {
  38.     return [self findLastInArray:arr
  39.                        occurance:4
  40.                             flag:-1
  41.                         position:0];
  42. }
  43.  
  44. - (NSInteger)findLastInArray:(NSArray *)arr occurance:(NSInteger)ocr  flag:(NSInteger)flag position:(NSInteger)pos {
  45.     if (pos >= [arr count]) {
  46.         return flag;
  47.     }
  48.    
  49.     if (ocr == [[arr objectAtIndex:pos] intValue]) {
  50.         flag = pos;
  51.     }
  52.    
  53.     return [self findLastInArray:arr
  54.                        occurance:ocr
  55.                             flag:flag
  56.                         position:++pos];
  57. }
  58.  
  59. @end