Search Results

Search found 3244 results on 130 pages for 'nil'.

Page 12/130 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • [obj-c] autorelease problem

    - by BQuadra
    Why the NSArray allocated with arrayWithObjects dealloc automatically if already used by BObject object?? in teory NSArray must remain allocated all the BObject life time... [[BObject alloc] initObjectName:@"oneObject" states: [NSArray arrayWithObjects: [[State alloc] initStateName:@"stand_front" singleImg:[NSArray arrayWithObjects:[UIImage imageNamed:@"front_1.png"], nil]], [[State alloc] initStateName:@"front_walking" frames: [NSArray arrayWithObjects: [UIImage imageNamed:@"front_1.png"], [UIImage imageNamed:@"front_2.png"], [UIImage imageNamed:@"front_3.png"], [UIImage imageNamed:@"front_4.png"], [UIImage imageNamed:@"front_5.png"], [UIImage imageNamed:@"front_6.png"], [UIImage imageNamed:@"front_7.png"], [UIImage imageNamed:@"front_8.png"], nil] duration:0.8 repeat:0], nil] isSolid:TRUE];

    Read the article

  • How to customize the pop up menu in iPhone?

    - by Allen Dang
    The application I'm creating needs a function like user selects some text, a pop up menu shows, and user clicks "search" menu to perform a search directly. Problem is the current pop up menu provided by UIMenuController doesn't support to be extended. So my thought is to subscribe "UIMenuControllerDidShowMenuNotification", get the frame of pop up menu, and display the "search" button right aside. But during the implementation, I met a strange problem, the notification seems never be sent, means after the menu shown, I still cannot be notified, following are the key section of code. - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuDidShow:) name:UIMenuControllerWillShowMenuNotification object:nil]; } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIMenuControllerDidShowMenuNotification object:nil]; self.textView = nil; self.searchBar = nil; } - (void)menuDidShow:(NSNotification *)notification { NSLog(@"menu did show!"); } The code is too simple to make mistake, can someone help me to understand what's going on? Or what did I miss?

    Read the article

  • Problems with ltk (common lisp)

    - by Silvanus
    I installed ltk to Steel Bank Common Lisp with asdf-install, but I can't even start using it V_V. The code below is the simplest example in the documentation, and is copied almost verbatim. asdf:operate 'asdf:load-op :ltk) (defun hello-1() (with-ltk () (let ((b (make-instance 'button :master nil :text "Press Me" :command (lambda () (format t "Hello World!~&"))))) (pack b)))) (hello-1) This is the error message I get from sbcl: ; in: LAMBDA NIL ; (PACK B) ; ; caught STYLE-WARNING: ; undefined function: PACK ; (WITH-LTK NIL ; (LET ((B (MAKE-INSTANCE 'BUTTON :MASTER NIL :TEXT "Press Me" :COMMAND #))) ; (PACK B))) ; ; caught STYLE-WARNING: ; undefined function: WITH-LTK ; ; compilation unit finished ; Undefined functions: ; PACK WITH-LTK ; caught 2 STYLE-WARNING conditions debugger invoked on a SIMPLE-ERROR in thread #: There is no class named BUTTON. Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL. restarts (invokable by number or by possibly-abbreviated name): 0: [ABORT] Exit debugger, returning to top level. (SB-PCL::FIND-CLASS-FROM-CELL BUTTON NIL T)

    Read the article

  • Declare in .h file? iPhone SDK

    - by Henry D'Andrea
    How would I declare this code in the header file (.h) in iPhone SDK? (void) save { UIGraphicsBeginImageContext(self.view.frame.size);  [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage, nilnil, nil); }

    Read the article

  • TableView frame not resizing properly when pushing a new view controller and the keyboard is hiding

    - by Pete
    Hi, I must be missing something fundamental here. I have a UITableView inside of a NavigationViewController. When a table row is selected in the UITableView (using tableView:didSelectRowAtIndexPath:) I call pushViewController to display a different view controller. The new view controller appears correctly, but when I pop that view controller and return the UITableView is resized as if the keyboard was being displayed. I need to find a way to have the keyboard hide before I push the view controller so that the frame is restored correctly. If I comment out the code to push the view controller then the keyboard hides correctly and the frame resizes correctly. The code I use to show the keyboard is as follows: - (void) keyboardDidShowNotification:(NSNotification *)inNotification { NSLog(@"Keyboard Show"); if (keyboardVisible) return; // We now resize the view accordingly to accomodate the keyboard being visible keyboardVisible = YES; CGRect bounds = [[[inNotification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; bounds = [self.view convertRect:bounds fromView:nil]; CGRect tableFrame = tableViewNewEntry.frame; tableFrame.size.height -= bounds.size.height; // subtract the keyboard height if (self.tabBarController != nil) { tableFrame.size.height += 48; // add the tab bar height } [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(shrinkDidEnd:finished:contextInfo:)]; tableViewNewEntry.frame = tableFrame; [UIView commitAnimations]; } The keyboard is hidden using: - (void) keyboardWillHideNotification:(NSNotification *)inNotification { if (!keyboardVisible) return; NSLog(@"Keyboard Hide"); keyboardVisible = FALSE; CGRect bounds = [[[inNotification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; bounds = [self.view convertRect:bounds fromView:nil]; CGRect tableFrame = tableViewNewEntry.frame; tableFrame.size.height += bounds.size.height; // add the keyboard height if (self.tabBarController != nil) { tableFrame.size.height -= 48; // subtract the tab bar height } tableViewNewEntry.frame = tableFrame; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(_shrinkDidEnd:finished:contextInfo:)]; tableViewNewEntry.frame = tableFrame; [UIView commitAnimations]; [tableViewNewEntry scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionMiddle animated:YES]; NSLog(@"Keyboard Hide Finished"); } I trigger the keyboard being hidden by resigning first responser for any control that is the first responder in ViewWillDisappear. I have added NSLog statements and see things happening in the log file as follows: Show Keyboard ViewWillDisappear: Hiding Keyboard Hide Keyboard Keyboard Hide Finished PushViewController (an NSLog entry at the point I push the new view controller) From this trace, I can see things happening in the right order, but It seems like when the view controller is pushed that the keyboard hide code does not execute properly. Any ideas would be really appreciated. I have been banging my head against the keyboard for a while trying to find out what I am doing wrong.

    Read the article

  • How to create an Universal Binary for iTunes Connect Distribution?

    - by balexandre
    I created an app that was rejected because Apple say that my App was not showing the correct iPad window and it was showing the same iPhone screen but top left aligned. Running on simulator, I get my App to show exactly what it should, a big iPad View. my app as Apple referees that is showing on device: my app running the simulator (50% zoom only): my code in the Application Delegate is the one I published before - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // The default have the line below, let us comment it //MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; // Our main controller MainViewController *aController = nil; // Is this OS 3.2.0+ ? #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) // It's an iPad, let's set the MainView to our MainView-iPad aController = [[MainViewController alloc] initWithNibName:@"MainView-iPad" bundle:nil]; else // This is a 3.2.0+ but not an iPad (for future, when iPhone/iPod Touch runs with same OS than iPad) aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; #else // It's an iPhone/iPod Touch (OS < 3.2.0) aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; #endif // Let's continue our default code self.mainViewController = aController; [aController release]; mainViewController.view.frame = [UIScreen mainScreen].applicationFrame; [window addSubview:[mainViewController view]]; [window makeKeyAndVisible]; return YES; } on my target info I have iPhone/iPad My question is, how should I build the app? Use Base SDK iPhone Simulator 3.1.3 iPhone Simulator 3.2 my Active Configuration is Distribution and Active Architecture is arm6 Can anyone that already published app into iTunes Connect explain me the settings? P.S. I followed the Developer Guideline on Building and Installing your Development Application that is found on Creating and Downloading Development Provisioning Profiles but does not say anything regarding this, as I did exactly and the app was rejected.

    Read the article

  • Accessing 2D array and passing string to label.text

    - by Amir
    Hi. I'm trying to create 2D array and initialize it with NSStrings. When I try to copy content of a cell from the array to a label.text, the application crashes. NSMutableArray *array = [NSMutableArray arrayWithCapacity:0]; [array addObject:[NSMutableArray arrayWithObjects: [NSArray arrayWithObjects: @"0-0", @"0-1", @"0-2", nil], [NSArray arrayWithObjects: @"1-0", @"1-1", @"1-2", nil], [NSArray arrayWithObjects: @"2-0", @"2-1", @"2-2", nil], nil]]; label.text = [[array objectAtIndex:0] objectAtIndex:0]; Any idea why and what am I doing wrong?

    Read the article

  • Rails: unable to set any attribute of child model

    - by Bryan Roth
    I'm having a problem instantiating a ListItem object with specified attributes. For some reason all attributes are set to nil even if I specify values. However, if I specify attributes for a List, they retain their values. Attributes for a List retain their values: >> list = List.new(:id => 20, :name => "Test List") => #<List id: 20, name: "Test List"> Attributes for a ListItem don't retain their values: >> list_item = ListItem.new(:id => 17, :list_id => 20, :name => "Test Item") => #<ListItem id: nil, list_id: nil, name: nil> UPDATE #1: I thought the id was the only attribute not retaining its value but realized that setting any attribute for a ListItem gets set to nil. list.rb: class List < ActiveRecord::Base has_many :list_items, :dependent => :destroy accepts_nested_attributes_for :list_items, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true end list_item.rb: class ListItem < ActiveRecord::Base belongs_to :list validates_presence_of :name end schema.rb ActiveRecord::Schema.define(:version => 20100506144717) do create_table "list_items", :force => true do |t| t.integer "list_id" t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "lists", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end end

    Read the article

  • cannot dismiss the email composer view in iphone?

    - by Warrior
    I am new to iphone development.I have created a tabbar based application . In the first i want the email composer to be displayed. I am able to display it but the cancel and send button are not working,I don't know where do i go wrong .Please help me out. Here is my code. - (void)viewDidLoad { [super viewDidLoad]; [self displayComposerSheet]; } -(void)displayComposerSheet { picker = [[MFMailComposeViewController alloc] init]; [[picker navigationBar] setTintColor:[UIColor blackColor]]; picker.mailComposeDelegate = self; if ([MFMailComposeViewController canSendMail]) { [picker setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]]; [picker setSubject:@"Sample"]; } [self.view addSubview:picker.view]; [self presentModalViewController:picker animated:YES]; } - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { switch (result) { case MFMailComposeResultCancelled: alert = [[UIAlertView alloc] initWithTitle:@"Message Cancelled!" message:@"Your email has cancelled to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [alert release]; break; case MFMailComposeResultSaved: alert = [[UIAlertView alloc] initWithTitle:@"Message Saved!" message:@"Your email has saved to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [alert release]; break; case MFMailComposeResultSent: alert = [[UIAlertView alloc] initWithTitle:@"Message Sent!" message:@"Your email has to sent" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [alert release];; break; case MFMailComposeResultFailed: alert = [[UIAlertView alloc] initWithTitle:@"Message Failed!" message:@"Your email has cancelled to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [alert show]; [alert release]; break; default: alert = [[UIAlertView alloc] initWithTitle:@"Message Failed!" message:@"Your email has not to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [alert release]; break; } [self dismissModalViewControllerAnimated:YES]; }

    Read the article

  • How to set the back groung color to the UIActionSheet in iPhone?

    - by Madan Mohan
    Hi Guys, I need to change the back ground colour of the action sheet, UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Create Estimate", @"Record Expense",@"Add Credit",@"Delete Customer", @"Cancel", nil]; actionSheet.actionSheetStyle = UIActionSheetStyleDefault; actionSheet.destructiveButtonIndex=3; [actionSheet showInView:appDelegate.window]; // show from our table view (pops up in the middle of the table) [actionSheet release]; please tell how to set the back ground color for action sheet.

    Read the article

  • objective-c default init method for class?

    - by Alex
    Hello, I have two differing methods for initializing my objective-c class. One is the default, and one takes a configuration parameter. Now, I'm pretty green when it comes to objective-c, but I've implemented these methods and I'm wondering if there's a better (more correct/in good style) way to handle initialization than the way I have done it. Meaning, did I write these initialization functions in accordance with standards and good style? It just doesn't feel right to check for the existence of selfPtr and then return based on that. Below are my class header and implementation files. Also, if you spot anything else that is wrong or evil, please let me know. I am a C++/Javascript developer who is learning objective-c as hobby and would appreciate any tips that you could offer. #import <Cocoa/Cocoa.h> // class for raising events and parsing returned directives @interface awesome : NSObject { // silence is golden. Actually properties are golden. Hence this emptiness. } // properties @property (retain) SBJsonParser* parser; @property (retain) NSString* eventDomain; @property (retain) NSString* appid // constructors -(id) init; -(id) initWithAppId:(id) input; // destructor -(void) dealloc; @end #import "awesome.h" #import "JSON.h" @implementation awesome - (id) init { if (self = [super init]) { // if init is called directly, just pass nil to AppId contructor variant id selfPtr = [self initWithAppId:nil]; } if (selfPtr) { return selfPtr; } else { return self; } } - (id) initWithAppId:(id) input { if (self = [super init]) { if (input = nil) { input = [[NSString alloc] initWithString:@"a369x123"]; } [self setAppid:input]; [self setEventDomain:[[NSString alloc] initWithString:@"desktop"]]; } return self; } // property synthesis @synthesize parser; @synthesize appid; @synthesize eventDomain; // destructor - (void) dealloc { self.parser = nil; self.appid = nil; self.eventDomain = nil; [super dealloc]; } @end Thanks!

    Read the article

  • Switching xib's in iPhone SDK?

    - by NextRev
    I'm having issues with switching xib's when I try to from my second view into the third. I get into the second view from the first like this... -(IBAction)startButtonClicked:(id)sender{ Number2ViewController *screen = [[Number2ViewController alloc] initWithNibName:nil bundle:nil]; screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentModalViewController:screen animated:YES]; [screen release]; } But when I'm in the second view trying to get to the third view, the app crashes... -(IBAction)nextButtonClicked:(id)sender{ Number3ViewController *screen = [[Number3ViewController alloc] initWithNibName:nil bundle:nil]; screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentModalViewController:screen animated:YES]; [screen release]; } I know how to go into one view and then immediately back using [self dismissModalViewControllerAnimated:YES]; How do you just keep going to different views though without having to go back first?

    Read the article

  • Capture iPhone screen with status bar included?

    - by Josh
    I am looking for a way to capture a screenshot on the iPhone with the top status bar included, I am currently using the following code: UIGraphicsBeginImageContext(self.view.bounds.size); //self.view.window.frame.size [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); The above code sucessfully takes a screenshot of the iPhone UIView but does not include the top status bar (In its place is just a blank 20px space).

    Read the article

  • UITableview has problem reloading

    - by seelani
    Hi guys, I've kinda finished my application for a school project but have run into a major "bug". It's a account management application. I'm unable to insert a picture here so here's a link: http://i232.photobucket.com/albums/ee112/seelani/Screenshot2010-12-22atPM075512.png Here's the problem when i click on the plus sign, i push a nav controller to load another view to handle the adding and deleting of categories. When i add and return back to the view above, it doesn't update. It only updates after i hit the button on the right which is another view used to change some settings, and return back to the page. I did some research on viewWillAppear and such but I'm still confused to why it doesn't work properly. This problem is also affecting my program when i delete a category, and return back to this view it crashes cos the view has not reloaded successfully. I will get this error when deleting and returning to the view. "* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSMutableArray objectAtIndex:]: index 4 beyond bounds [0 .. 3]'". [EDIT] Table View Code: @class LoginViewController; @implementation CategoryTableViewController @synthesize categoryTableViewController; @synthesize categoryArray; @synthesize accountsTableViewController; @synthesize editAccountTable; @synthesize window; CategoryMgmtTableController *categoryMgmtTableController; ChangePasswordView *changePasswordView; - (void) save_Clicked:(id)sender { /* UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Category Management" message:@"Load category management table view" delegate:self cancelButtonTitle: @"OK" otherButtonTitles:nil]; [alert show]; [alert release]; */ KeyCryptAppAppDelegate *appDelegate = (KeyCryptAppAppDelegate *)[[UIApplication sharedApplication] delegate]; categoryMgmtTableController = [[CategoryMgmtTableController alloc]initWithNibName:@"CategoryMgmtTable" bundle:nil]; [appDelegate.categoryNavController pushViewController:categoryMgmtTableController animated:YES]; } - (void) change_Clicked:(id)sender { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Change Password" message:@"Change password View" delegate:self cancelButtonTitle: @"OK" otherButtonTitles:nil]; [alert show]; [alert release]; KeyCryptAppAppDelegate *appDelegate = (KeyCryptAppAppDelegate *)[[UIApplication sharedApplication] delegate]; changePasswordView = [[ChangePasswordView alloc]initWithNibName:@"ChangePasswordView" bundle:nil]; [appDelegate.categoryNavController pushViewController:changePasswordView animated:YES]; /* KeyCryptAppAppDelegate *appDelegate = (KeyCryptAppAppDelegate *)[[UIApplication sharedApplication] delegate]; categoryMgmtTableController = [[CategoryMgmtTableController alloc]initWithNibName:@"CategoryMgmtTable" bundle:nil]; [appDelegate.categoryNavController pushViewController:categoryMgmtTableController animated:YES]; */ } #pragma mark - #pragma mark Initialization /* - (id)initWithStyle:(UITableViewStyle)style { // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. if ((self = [super initWithStyle:style])) { } return self; } */ -(void) initializeCategoryArray { sqlite3 *db= [KeyCryptAppAppDelegate getNewDBConnection]; KeyCryptAppAppDelegate *appDelegate = (KeyCryptAppAppDelegate *)[[UIApplication sharedApplication] delegate]; const char *sql = [[NSString stringWithFormat:(@"Select Category from Categories;")]cString]; const char *cmd = [[NSString stringWithFormat:@"pragma key = '%@' ", appDelegate.pragmaKey]cString]; sqlite3_stmt *compiledStatement; sqlite3_exec(db, cmd, NULL, NULL, NULL); if (sqlite3_prepare_v2(db, sql, -1, &compiledStatement, NULL)==SQLITE_OK) { while(sqlite3_step(compiledStatement) == SQLITE_ROW) [categoryArray addObject:[NSString stringWithUTF8String:(char*) sqlite3_column_text(compiledStatement, 0)]]; } else { NSAssert1(0,@"Error preparing statement", sqlite3_errmsg(db)); } sqlite3_finalize(compiledStatement); } #pragma mark - #pragma mark View lifecycle - (void)viewDidLoad { // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; [super viewDidLoad]; } - (void)viewWillAppear:(BOOL)animated { self.title = NSLocalizedString(@"Categories",@"Types of Categories"); categoryArray = [[NSMutableArray alloc]init]; [self initializeCategoryArray]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(save_Clicked:)] autorelease]; self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(change_Clicked:)] autorelease]; [super viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { NSLog (@"view did appear"); [super viewDidAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated { NSLog (@"view will disappear"); [super viewWillDisappear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [categoryTableView reloadData]; NSLog (@"view did disappear"); [super viewDidDisappear:animated]; } /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ #pragma mark - #pragma mark Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [self.categoryArray count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell... NSUInteger row = [indexPath row]; cell.text = [categoryArray objectAtIndex:row]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } /* // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; } */ /* // Override to support editing the table view. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view } } */ /* // Override to support rearranging the table view. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { } */ /* // Override to support conditional rearranging of the table view. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the item to be re-orderable. return YES; } */ #pragma mark - #pragma mark Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *selectedCategory = [categoryArray objectAtIndex:[indexPath row]]; NSLog (@"AccountsTableView.xib is called."); if ([categoryArray containsObject: selectedCategory]) { if (self.accountsTableViewController == nil) { AccountsTableViewController *aAccountsView = [[AccountsTableViewController alloc]initWithNibName:@"AccountsTableView"bundle:nil]; self.accountsTableViewController =aAccountsView; [aAccountsView release]; } NSInteger row =[indexPath row]; accountsTableViewController.title = [NSString stringWithFormat:@"%@", [categoryArray objectAtIndex:row]]; // This portion pushes the categoryNavController. KeyCryptAppAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [self.accountsTableViewController initWithTextSelected:selectedCategory]; KeyCryptAppAppDelegate *appDelegate = (KeyCryptAppAppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.pickedCategory = selectedCategory; [delegate.categoryNavController pushViewController:accountsTableViewController animated:YES]; } } #pragma mark - #pragma mark Memory management - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Relinquish ownership any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. // For example: self.myOutlet = nil; } - (void)dealloc { [accountsTableViewController release]; [super dealloc]; } @end And the code that i used to delete rows(this is in a totally different tableview): - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source NSString *selectedCategory = [categoryArray objectAtIndex:indexPath.row]; [categoryArray removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; [deleteCategoryTable reloadData]; //NSString *selectedCategory = [categoryArray objectAtIndex:indexPath.row]; sqlite3 *db= [KeyCryptAppAppDelegate getNewDBConnection]; KeyCryptAppAppDelegate *appDelegate = (KeyCryptAppAppDelegate *)[[UIApplication sharedApplication] delegate]; const char *sql = [[NSString stringWithFormat:@"Delete from Categories where Category = '%@';", selectedCategory]cString]; const char *cmd = [[NSString stringWithFormat:@"pragma key = '%@' ", appDelegate.pragmaKey]cString]; sqlite3_stmt *compiledStatement; sqlite3_exec(db, cmd, NULL, NULL, NULL); if (sqlite3_prepare_v2(db, sql, -1, &compiledStatement, NULL)==SQLITE_OK) { sqlite3_exec(db,sql,NULL,NULL,NULL); } else { NSAssert1(0,@"Error preparing statement", sqlite3_errmsg(db)); } sqlite3_finalize(compiledStatement); } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view } }

    Read the article

  • collision with moving objects

    - by blacksheep
    tried to write a collision with the moving "floats" but did not succeed. maybe wrong place of the "collision" code? thanx 4 help! // // FruitsView.m // import "FruitsView.h" import "Constants.h" import "Utilities.h" define kFloat1Speed 0.15 define kFloat2Speed 0.3 define kFloat3Speed 0.2 @interface FruitsView (Private) - (void) stopTimer; @end @implementation FruitsView @synthesize apple, float1, float2, float3, posFloat1, posFloat2, posFloat3; -(void)onTimer { float1.center = CGPointMake(float1.center.x+posFloat1.x,float1.cen ter.y+posFloat1.y); if(float1.center.x 380 || float1.center.x < -60) posFloat1.x = -posFloat1.x; if(float1.center.y 100 || float1.center.y < -40) posFloat1.y = -posFloat1.y; float2.center = CGPointMake(float2.center.x+posFloat2.x,float2.cen ter.y+posFloat2.y); if(float2.center.x 380 || float2.center.x < -50) posFloat2.x = -posFloat2.x; if(float2.center.y 150 || float2.center.y < -30) posFloat2.y = -posFloat2.y; float3.center = CGPointMake(float3.center.x+posFloat3.x,float3.cen ter.y+posFloat3.y); if(float3.center.x 380 || float3.center.x < -70) posFloat3.x = -posFloat3.x; if(float3.center.y 100 || float3.center.y < -20) posFloat3.y = -posFloat3.y; if(CGRectIntersectsRect(apple.frame,float1.frame)) { if(apple.center.y float1.center.y) { posApple.y = -posApple.y; } } if(CGRectIntersectsRect(apple.frame,float2.frame)) { if(apple.center.y float2.center.y) { posFloat2.y = -posFloat2.y; } } if(CGRectIntersectsRect(apple.frame,float3.frame)) { if(apple.center.y float3.center.y) { posFloat3.y = -posFloat3.y; } } } pragma mark Initialisation/destruction (void)awakeFromNib { [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(onTimer) userInfo:nil repeats:YES]; posFloat1 = CGPointMake(kFloat1Speed, 0); posFloat2 = CGPointMake(kFloat2Speed, 0); posFloat3 = CGPointMake(kFloat3Speed, 0); timer = nil; modeLock = lockNotYetChosen; defaultSize = self.bounds.size.width; modal = self.tag; [[UIAccelerometer sharedAccelerometer] setDelegate:self]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationRepeatCount:1]; eadbea.transform = CGAffineTransformMakeScale(0.5,0.5); [UIView commitAnimations]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationRepeatCount:1]; apple.transform = CGAffineTransformMakeScale(0.5,0.5); [UIView commitAnimations]; } pragma mark Background animation processing (void) startTimer { if (!timer) { timer = [[NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(timerTick:) userInfo:nil repeats:YES] retain]; } } (void) stopTimer { [timer invalidate]; [timer release]; timer = nil; } (void) check:(CGPoint*)position delta:(CGSize*)delta halfSize:(CGSize)halfSize forBouncingAgainst:(CGSize)containerSize { if ((position-x - halfSize.width)<0) { delta-width = fabsf(delta-width)*BOUNCE_DAMPING; position-x = halfSize.width; } if ((position-x + halfSize.width)containerSize.width) { delta-width = fabsf(delta-width)*-BOUNCE_DAMPING; position-x = containerSize.width - halfSize.width; } if ((position-y - halfSize.height)<0) { delta-height = fabsf(delta-height)*BOUNCE_DAMPING; position-y = halfSize.height; } if ((position-y + halfSize.height)containerSize.height) { delta-height = fabsf(delta-height)*-BOUNCE_DAMPING; position-y = containerSize.height - halfSize.height; } } (void) timerTick: (NSTimer*)timer { dragDelta = CGSizeScale(dragDelta, INERTIAL_DAMPING); if ((fabsf(dragDelta.width)DELTA_ZERO_THRESHOLD) || (fabsf(dragDelta.height)DELTA_ZERO_THRESHOLD)) { CGPoint ctr = CGPointApplyDelta(self.center, dragDelta); CGSize halfSize = CGSizeMake(self.bounds.size.width/4, self.bounds.size.height/4); [self check:&ctr delta:&dragDelta halfSize:halfSize forBouncingAgainst:self.superview.bounds.size]; self.center = ctr; } else { [self stopTimer]; } } pragma mark Input Handling (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent )event { NSSet allTouches = [event touchesForView:self]; if ([allTouches count]==1) { if (modeLocklockNotYetChosen) return; UITouch* anyTouch = [touches anyObject]; lastMove = anyTouch.timestamp; CGPoint now = [anyTouch locationInView: self.superview]; CGPoint then = [anyTouch previousLocationInView: self.superview]; dragDelta = CGPointDelta(now, then); self.center = CGPointApplyDelta(self.center, dragDelta); [self stopTimer]; } } (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSSet* allTouches = [event touchesForView:self]; if ([touches count]==[allTouches count]) { modeLock = lockNotYetChosen; if ((event.timestamp - lastMove) MOVEMENT_PAUSE_THRESHOLD) return; if ((fabsf(dragDelta.width)INERTIA_THRESHOLD) || (fabsf(dragDelta.height)INERTIA_THRESHOLD)) { [self startTimer]; } } } (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { modeLock = lockNotYetChosen; [self stopTimer]; } (void)dealloc { [float1 release]; [float2 release]; [float3 release]; [apple release]; [bear_head release]; [self stopTimer]; [super dealloc]; } @end

    Read the article

  • My App crashes when launched on my Iphone

    - by Miky Mike
    hi guys, I have a problem here : my app crashed on my Iphone (JB) though Xcode doesn't complain about anything. The app works fine on the simulator though. However, there is this in the device logs : Thread 0 Crashed: 0 libSystem.B.dylib 0x00078ac8 kill + 8 1 libSystem.B.dylib 0x00078ab8 kill + 4 2 libSystem.B.dylib 0x00078aaa raise + 10 3 libSystem.B.dylib 0x0008d03a abort + 50 4 libstdc++.6.dylib 0x00044a20 __gnu_cxx::__verbose_terminate_handler() + 376 5 libobjc.A.dylib 0x00005958 _objc_terminate + 104 6 libstdc++.6.dylib 0x00042df2 _cxxabiv1::_terminate(void (*)()) + 46 7 libstdc++.6.dylib 0x00042e46 std::terminate() + 10 8 libstdc++.6.dylib 0x00042f16 __cxa_throw + 78 9 libobjc.A.dylib 0x00004838 objc_exception_throw + 64 10 CoreFoundation 0x0009fd0e +[NSException raise:format:arguments:] + 62 11 CoreFoundation 0x0009fd48 +[NSException raise:format:] + 28 12 Foundation 0x000125d8 -[NSURL(NSURL) initFileURLWithPath:] + 64 13 Foundation 0x000371e0 +[NSURL(NSURL) fileURLWithPath:] + 24 14 TheLearningMachine 0x00002d08 0x1000 + 7432 15 TheLearningMachine 0x00002e8c 0x1000 + 7820 16 TheLearningMachine 0x00002be4 0x1000 + 7140 17 TheLearningMachine 0x000029b6 0x1000 + 6582 18 UIKit 0x0000e47a -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 766 19 UIKit 0x000049e0 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 200 20 UIKit 0x0005dfd6 -[UIApplication handleEvent:withNewEvent:] + 1390 21 UIKit 0x0005d8fa -[UIApplication sendEvent:] + 38 22 UIKit 0x0005d330 _UIApplicationHandleEvent + 5104 23 GraphicsServices 0x00005044 PurpleEventCallback + 660 24 CoreFoundation 0x00034cdc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 20 25 CoreFoundation 0x00034ca0 __CFRunLoopDoSource1 + 160 26 CoreFoundation 0x00027566 __CFRunLoopRun + 514 27 CoreFoundation 0x00027270 CFRunLoopRunSpecific + 224 28 CoreFoundation 0x00027178 CFRunLoopRunInMode + 52 29 UIKit 0x000040fc -[UIApplication _run] + 364 30 UIKit 0x00002128 UIApplicationMain + 664 31 TheLearningMachine 0x00002948 0x1000 + 6472 32 TheLearningMachine 0x000028fc 0x1000 + 6396 Thread 1: 0 libSystem.B.dylib 0x0002d330 kevent + 24 1 libSystem.B.dylib 0x000d6b6c _dispatch_mgr_invoke + 88 2 libSystem.B.dylib 0x000d65bc _dispatch_queue_invoke + 96 3 libSystem.B.dylib 0x000d675c _dispatch_worker_thread2 + 120 4 libSystem.B.dylib 0x0007a67a _pthread_wqthread + 258 5 libSystem.B.dylib 0x00073190 start_wqthread + 0 Thread 2: 0 libSystem.B.dylib 0x0007b19c __workq_kernreturn + 8 1 libSystem.B.dylib 0x0007a790 _pthread_wqthread + 536 2 libSystem.B.dylib 0x00073190 start_wqthread + 0 Thread 3: 0 libSystem.B.dylib 0x00000c98 mach_msg_trap + 20 1 libSystem.B.dylib 0x00002d64 mach_msg + 44 2 CoreFoundation 0x00027c38 __CFRunLoopServiceMachPort + 88 3 CoreFoundation 0x000274c2 __CFRunLoopRun + 350 4 CoreFoundation 0x00027270 CFRunLoopRunSpecific + 224 5 CoreFoundation 0x00027178 CFRunLoopRunInMode + 52 6 WebCore 0x000024e2 RunWebThread(void*) + 362 7 libSystem.B.dylib 0x0007a27e _pthread_start + 242 8 libSystem.B.dylib 0x0006f2a8 thread_start + 0 Thread 0 crashed with ARM Thread State: r0: 0x00000000 r1: 0x00000000 r2: 0x00000001 r3: 0x3e0862b4 r4: 0x00000006 r5: 0x0015a2ec r6: 0x2fffe090 r7: 0x2fffe0a0 r8: 0x3e1a378c r9: 0x00000065 r10: 0x33028e5a r11: 0x3e1ab89c ip: 0x00000025 sp: 0x2fffe0a0 lr: 0x30277abf pc: 0x30277ac8 cpsr: 0x000f0010 Any idea what the problem can be ? I've already spent my whole day on that, but... I'm stuck. Thanks in advance... Miky Mike Ok, Here is more then from the console, I get this : This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys002 Loading program into debugger… Program loaded. target remote-mobile /tmp/.XcodeGDBRemote-17280-65 Switching to remote-macosx protocol mem 0x1000 0x3fffffff cache mem 0x40000000 0xffffffff none mem 0x00000000 0x0fff none run Running… Error launching remote program: failed to get the task for process 456. Error launching remote program: failed to get the task for process 456. The program being debugged is not being run. The program being debugged is not being run. [Session started at 2010-12-23 20:33:33 +0100.] GNU gdb 6.3.50-20050815 (Apple version gdb-1472) (Thu Aug 5 05:54:10 UTC 2010) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys004 Loading program into debugger… Program loaded. target remote-mobile /tmp/.XcodeGDBRemote-17280-72 Switching to remote-macosx protocol mem 0x1000 0x3fffffff cache mem 0x40000000 0xffffffff none mem 0x00000000 0x0fff none run Running… Error launching remote program: failed to get the task for process 508. Error launching remote program: failed to get the task for process 508. The program being debugged is not being run. The program being debugged is not being run. And here is the code page that calls the URL import "TheLearningMachineAppDelegate.h" import "RootViewController.h" @implementation TheLearningMachineAppDelegate @synthesize window; @synthesize navigationController; pragma mark - pragma mark Application lifecycle (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { RootViewController *rootViewController = (RootViewController *)[navigationController topViewController]; rootViewController.managedObjectContext = self.managedObjectContext; [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; return YES; } (void)applicationWillResignActive:(UIApplication )application { / Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. */ } (void)applicationDidEnterBackground:(UIApplication *)application { [self saveContext]; } (void)applicationWillEnterForeground:(UIApplication )application { / Called as part of the transition from the background to the inactive state: here you can undo many of the changes made on entering the background. */ } (void)applicationDidBecomeActive:(UIApplication )application { / Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. */ } // Method that saves the managed object context before the application terminates. (void)applicationWillTerminate:(UIApplication *)application { [self saveContext]; } (void)saveContext { NSError *error = nil; if (managedObjectContext != nil) { if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); //Replace this implementation with code to handle the error appropriately. //abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button. } } } pragma mark - pragma mark Core Data stack // Returns the managed object context for the application. (NSManagedObjectContext *)managedObjectContext { if (managedObjectContext != nil) { return managedObjectContext; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { managedObjectContext = [[NSManagedObjectContext alloc] init]; [managedObjectContext setPersistentStoreCoordinator:coordinator]; } return managedObjectContext; } // Returns the managed object model for the application. (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel != nil) { return managedObjectModel; } NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"TheLearningMachine" ofType:@"momd"]; NSURL *modelURL = [NSURL fileURLWithPath:modelPath]; managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; return managedObjectModel; } pragma mark - pragma mark Application's Documents directory // Returns the path to the application's Documents directory. - (NSString *)applicationDocumentsDirectory { return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; } // Returns the persistent store coordinator for the application. - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeURL = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"TheLearningMachine.sqlite"]]; NSError *error = nil; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } return persistentStoreCoordinator; } pragma mark - pragma mark Memory management (void)applicationDidReceiveMemoryWarning:(UIApplication )application { / Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. */ } (void)dealloc { [managedObjectContext release]; [managedObjectModel release]; [persistentStoreCoordinator release]; [window release]; [super dealloc]; } @end

    Read the article

  • How to hide graph on button click ?

    - by aman-gupta
    Hi, In my application I m using following codes to draw a graph but I want that graph will be displayed on button click :- import @interface frmGraphView : UIView { } @end ///////////////////// // // frmGraphView.m // UV Alarm // // Created by Aman on 4/4/10. // Copyright 2010 MyCompanyName. All rights reserved. // import "frmGraphView.h" @implementation frmGraphView struct TCo_ordinates { float x; float y; }; (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } /* // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } */ /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ -(void)drawHGrid { //struct gridForXYaxis *gridForX = (struct gridForX *) calloc(sizeof(struct gridFor)) } (void)drawRect:(CGRect)rect { ifdef _DEBUG NSLog(@"frmGraph_drawRect_start"); endif CGContextRef ctx = UIGraphicsGetCurrentContext(); struct TCo_ordinates *tCoordianates; //creating the object of structure. float fltX1,fltX2,fltY1,fltY2=0; //Dividing the Y-axis ifdef _DEBUG NSLog(@"Start drawing Y-Axis"); endif fltX1 = 25; fltY1 = 2; fltX2 = fltX1; fltY2 = 254; //CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0); CGContextSetLineWidth(ctx, 2.0); CGContextMoveToPoint(ctx, fltX1, fltY1); CGContextAddLineToPoint(ctx, fltX2, fltY2); NSArray *hoursInDays = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12", nil]; NSMutableArray *yAxisCoordinates = [[[NSMutableArray alloc] init] autorelease]; for(int intIndex = 0 ; intIndex < [hoursInDays count] ; fltY2-=20, intIndex++) { ifdef _DEBUG NSLog(@"Start of the partition of y axis"); endif //CGContextSetRGBStrokeColor(ctx, 2, 2, 2, 1); //CGContextSetRGBStrokeColor(ctx, 1.0f/255.0f, 1.0f/255.0f, 1.0f/255.0f, 1.0f); //to draw the black line. CGContextMoveToPoint(ctx, fltX1-3 , fltY2-20); CGContextAddLineToPoint(ctx, fltX1+3, fltY2-20); CGContextSelectFont(ctx, "Helvetica", 12.0, kCGEncodingMacRoman); CGContextSetTextDrawingMode(ctx, kCGTextFill); //CGContextSetRGBFillColor(ctx, 0, 255, 255, 1); CGContextSetStrokeColorWithColor(ctx, [UIColor blueColor].CGColor); CGAffineTransform xform = CGAffineTransformMake( 1.0, 0.0, 0.0, -1.0, 0.0, 0.0); CGContextSetTextMatrix(ctx, xform); const char *arrayDataForYAxis = [[hoursInDays objectAtIndex:intIndex] UTF8String]; CGContextShowTextAtPoint(ctx,fltX1-20 , fltY2-15, arrayDataForYAxis, strlen(arrayDataForYAxis)); CGContextStrokePath(ctx); ifdef _DEBUG NSLog(@"End of the partition of graph"); endif //NSValue *yAxis = [NSValue valueWithCGPoint:CGPointMake((tCoordianates-x = fltX1-21), (tCoordianates-y = fltY2-20))]; // [yAxisCoordinates addObject:yAxis]; ifdef _DEBUG // NSLog(@"The value of yAxisCoordintes: %@", yAxisCoordinates); endif } ifdef _DEBUG NSLog(@"End of drawing Y-Axis"); endif //Dividing the X-axis ifdef _DEBUG NSLog(@"Start drawing X-Axis"); endif fltX1 = 25; fltY1 = 255; fltX2 = 320; fltY2 = fltY1; CGContextMoveToPoint(ctx, fltX1, fltY1); CGContextAddLineToPoint(ctx, fltX2, fltY2); //CGContextSetRGBStrokeColor(ctx, 2, 2, 2, 1); CGContextSetLineWidth(ctx, 2.0); NSArray *weekDays =[[NSArray alloc] initWithObjects:@"Sun", @"Mon", @"Tue", @"Wed", @"Thu", @"Fri", @"Sat", nil]; NSMutableArray *xAxisCoordinates = [[[NSMutableArray alloc] init] autorelease]; for(int intIndex = 0 ; intIndex < [weekDays count] ; fltX1+=40, intIndex++) { //CGContextSetRGBStrokeColor(ctx, 2, 2, 2, 1); //CGContextSetStrokeColorWithColor(ctx, [UIColor orangeColor].CGColor); CGContextMoveToPoint(ctx, fltX1+40 , fltY2-3); CGContextAddLineToPoint(ctx, fltX1+40, fltY2+3); CGContextSelectFont(ctx, "Italic", 12.0, kCGEncodingMacRoman); CGContextSetTextDrawingMode(ctx, kCGTextFill); CGContextSetStrokeColorWithColor(ctx, [UIColor blueColor].CGColor); CGAffineTransform xform = CGAffineTransformMake( 1.0, 0.0, 0.0, -1.0, 0.0, 0.0); CGContextSetTextMatrix(ctx, xform); const char *arrayDataForXAxis = [[weekDays objectAtIndex:intIndex] UTF8String]; CGContextShowTextAtPoint(ctx, fltX1+27, fltY2+20 , arrayDataForXAxis, strlen(arrayDataForXAxis)); CGContextStrokePath(ctx); ifdef _DEBUG NSLog(@"End of drawing X-Axis"); endif //NSValue *xAxis = [NSValue valueWithCGPoint:CGPointMake((tCoordianates->x = fltX1+40), (tCoordianates->y = fltY2+18))]; // [xAxisCoordinates addObject:xAxis]; ifdef _DEBUG //NSLog(@"The value of xAxisCoordintes: %@", xAxisCoordinates); NSLog(@"frmGraph_drawRect_end"); endif } CGContextSetLineWidth(ctx, 10.0); fltX1 = 25; fltY1 = 235; fltX2 = 320; fltY2 = fltY1; NSArray *coordinate1 = [[NSArray alloc] initWithObjects:@"65",@"105",@"145",@"185",@"225",@"265",@"305",nil]; NSArray *coordinate2 = [[NSArray alloc] initWithObjects:@"214",@"174",@"154",@"134",@"114",@"74",@"34",nil]; ifdef _DEBUG NSLog(@"Fuction of Bar_start"); endif for(int intIndex = 0; intIndex < [coordinate1 count], intIndex < [coordinate2 count]; fltX1+=40, intIndex++) { //CGContextSetRGBFillColor(ctx, 0, 0, 245, 1); CGContextMoveToPoint(ctx, fltX1+40, fltY2+19); const char *arrayDataForCoordinate1 = [[coordinate1 objectAtIndex:intIndex] UTF8String]; const char *arrayDataForCoordinate2 = [[coordinate2 objectAtIndex:intIndex] UTF8String]; CGContextAddLineToPoint(ctx, (atof(arrayDataForCoordinate1)), atof(arrayDataForCoordinate2)); } ifdef _DEBUG NSLog(@"Fuction of Bar_end"); endif CGContextClosePath(ctx); CGContextStrokePath(ctx); [hoursInDays release]; [weekDays release]; [coordinate1 release]; [coordinate2 release]; hoursInDays = nil; weekDays = nil; coordinate1 = nil; coordinate2 = nil; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } (void)dealloc { [super dealloc]; } @end please help me out its urgent

    Read the article

  • Core data setReturnsDistinctResult not working

    - by Moze
    So i'm building a small application, it uses core data database of ~25mb size with 4 entities. It's for bus timetables. In one table named "Stop" there are have ~1300 entries of bus stops with atributes "name", "id", "longitude", "latitude" and couple relationships. Now there are many stops with same name but different coordinates and id. Search is implemented using NSPredicate. So I want to show all distinct stop names in table view, i'm using setReturnsDistinctResults with NSDictionaryResultType and setPropertiesToFetch. But setReturnsDistinctResult is not working and I'm still getting all entries. Heres code: - (NSFetchRequest *)fetchRequest { if (fetchRequest == nil) { fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Stop" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSArray *sortDescriptors = [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES] autorelease]]; [fetchRequest setSortDescriptors:sortDescriptors]; [fetchRequest setResultType:NSDictionaryResultType]; [fetchRequest setPropertiesToFetch:[NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"name"]]]; [fetchRequest setReturnsDistinctResults:YES]; DebugLog(@"fetchRequest initialized"); } return fetchRequest; } ///////////////////// - (NSFetchedResultsController *)fetchedResultsController { if (self.predicateString != nil) { self.predicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@", self.predicateString]; [self.fetchRequest setPredicate:predicate]; } else { self.predicate = nil; [self.fetchRequest setPredicate:predicate]; } fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:self.fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:sectionNameKeyPath cacheName:nil]; return fetchedResultsController; } ////////////// - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [[fetchedResultsController objectAtIndexPath:indexPath] valueForKey:@"name"]; return cell; }

    Read the article

  • Delphi - Using DeviceIoControl passing IOCTL_DISK_GET_LENGTH_INFO to get flash media physical size (Not Partition)

    - by SuicideClutchX2
    Alright this is the result of a couple of other questions. It appears I was doing something wrong with the suggestions and at this point have come up with an error when using the suggested API to get the media size. Those new to my problem I am working at the physical disk level, not within the confines of a partition or file system. Here is the pastebin code for the main unit (Delphi 2009) - http://clutchx2.pastebin.com/iMnq8kSx Here is the application source and executable with a form built to output the status of whats going on - http://www.mediafire.com/?js8e6ci8zrjq0de Its probably easier to use the download, unless your just looking for problems within the code. I will also paste the code here. unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TfrmMain = class(TForm) edtDrive: TEdit; lblDrive: TLabel; btnMethod1: TButton; btnMethod2: TButton; lblSpace: TLabel; edtSpace: TEdit; lblFail: TLabel; edtFail: TEdit; lblError: TLabel; edtError: TEdit; procedure btnMethod1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; TDiskExtent = record DiskNumber: Cardinal; StartingOffset: Int64; ExtentLength: Int64; end; DISK_EXTENT = TDiskExtent; PDiskExtent = ^TDiskExtent; TVolumeDiskExtents = record NumberOfDiskExtents: Cardinal; Extents: array[0..0] of TDiskExtent; end; VOLUME_DISK_EXTENTS = TVolumeDiskExtents; PVolumeDiskExtents = ^TVolumeDiskExtents; var frmMain: TfrmMain; const FILE_DEVICE_DISK = $00000007; METHOD_BUFFERED = 0; FILE_ANY_ACCESS = 0; IOCTL_DISK_BASE = FILE_DEVICE_DISK; IOCTL_VOLUME_BASE = DWORD('V'); IOCTL_DISK_GET_LENGTH_INFO = $80070017; IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS = ((IOCTL_VOLUME_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or (0 shl 2) or METHOD_BUFFERED); implementation {$R *.dfm} function GetLD(Drive: Char): Cardinal; var Buffer : String; begin Buffer := Format('\\.\%s:',[Drive]); Result := CreateFile(PChar(Buffer),GENERIC_READ Or GENERIC_WRITE,FILE_SHARE_READ,nil,OPEN_EXISTING,0,0); If Result = INVALID_HANDLE_VALUE Then begin Result := CreateFile(PChar(Buffer),GENERIC_READ,FILE_SHARE_READ,nil,OPEN_EXISTING,0,0); end; end; function GetPD(Drive: Byte): Cardinal; var Buffer : String; begin If Drive = 0 Then begin Result := INVALID_HANDLE_VALUE; Exit; end; Buffer := Format('\\.\PHYSICALDRIVE%d',[Drive]); Result := CreateFile(PChar(Buffer),GENERIC_READ Or GENERIC_WRITE,FILE_SHARE_READ,nil,OPEN_EXISTING,0,0); If Result = INVALID_HANDLE_VALUE Then begin Result := CreateFile(PChar(Buffer),GENERIC_READ,FILE_SHARE_READ,nil,OPEN_EXISTING,0,0); end; end; function GetPhysicalDiskNumber(Drive: Char): Byte; var LD : DWORD; DiskExtents : PVolumeDiskExtents; DiskExtent : TDiskExtent; BytesReturned : Cardinal; begin Result := 0; LD := GetLD(Drive); If LD = INVALID_HANDLE_VALUE Then Exit; Try DiskExtents := AllocMem(Max_Path); DeviceIOControl(LD,IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,nil,0,DiskExtents,Max_Path,BytesReturned,nil); If DiskExtents^.NumberOfDiskExtents > 0 Then begin DiskExtent := DiskExtents^.Extents[0]; Result := DiskExtent.DiskNumber; end; Finally CloseHandle(LD); end; end; procedure TfrmMain.btnMethod1Click(Sender: TObject); var PD : DWORD; CardSize: Int64; BytesReturned: DWORD; CallSuccess: Boolean; begin PD := GetPD(GetPhysicalDiskNumber(edtDrive.Text[1])); If PD = INVALID_HANDLE_VALUE Then Begin ShowMessage('Invalid Physical Disk Handle'); Exit; End; CallSuccess := DeviceIoControl(PD, IOCTL_DISK_GET_LENGTH_INFO, nil, 0, @CardSize, SizeOf(CardSize), BytesReturned, nil); if not CallSuccess then begin edtError.Text := IntToStr(GetLastError()); edtFail.Text := 'True'; end else edtFail.Text := 'False'; CloseHandle(PD); end; end. I placed a second method button on the form so I can write a different set of code into the app if I feel like it. Only minimal error handling and safeguards are there is nothing that wasn't necessary for debugging this via source. I tried this on a Sony Memory Stick using a PSP as the reader because I cant find the adapter for using a duo in my machine. The target is an MS and half of my users use a PSP for a reader half dont. However this should work fine on SD cards and that is a secondary target for my work as well. I tried this on a usb memory card reader and several SD cards. Now that I have fixed my attempt I get an error returned. 50 ERROR_NOT_SUPPORTED The request is not supported. I have found an application that uses this API as well as alot of related functions for what I am trying todo. I am getting ready to look into it the application is called DriveImage and its source is here - http://sourceforge.net/projects/diskimage/ The only thing I have really noticed from that application is there use of TFileStream and using that to get a handle on the physical disk.

    Read the article

  • how do you make a "concurrent queue safe" lazy loader (singleton manager) in objective-c

    - by Rich
    Hi, I made this class that turns any object into a singleton, but I know that it's not "concurrent queue safe." Could someone please explain to me how to do this, or better yet, show me the code. To be clear I want to know how to use this with operation queues and dispatch queues (NSOperationQueue and Grand Central Dispatch) on iOS. Thanks in advance, Rich EDIT: I had an idea for how to do it. If someone could confirm it for me I'll do it and post the code. The idea is that proxies make queues all on their own. So if I make a mutable proxy (like Apple does in key-value coding/observing) for any object that it's supposed to return, and always return the same proxy for the same object/identifier pair (using the same kind of lazy loading technique as I used to create the singletons), the proxies would automatically queue up the any messages to the singletons, and make it totally thread safe. IMHO this seems like a lot of work to do, so I don't want to do it if it's not gonna work, or if it's gonna slow my apps down to a crawl. Here's my non-thread safe code: RMSingletonCollector.h // // RMSingletonCollector.h // RMSingletonCollector // // Created by Rich Meade-Miller on 2/11/11. // Copyright 2011 Rich Meade-Miller. All rights reserved. // #import <Foundation/Foundation.h> #import "RMWeakObjectRef.h" struct RMInitializerData { // The method may take one argument. // required SEL designatedInitializer; // data to pass to the initializer or nil. id data; }; typedef struct RMInitializerData RMInitializerData; RMInitializerData RMInitializerDataMake(SEL initializer, id data); @interface NSObject (SingletonCollector) // Returns the selector and data to pass to it (if the selector takes an argument) for use when initializing the singleton. // If you override this DO NOT call super. + (RMInitializerData)designatedInitializerForIdentifier:(NSString *)identifier; @end @interface RMSingletonCollector : NSObject { } + (id)collectionObjectForType:(NSString *)className identifier:(NSString *)identifier; + (id<RMWeakObjectReference>)referenceForObjectOfType:(NSString *)className identifier:(NSString *)identifier; + (void)destroyCollection; + (void)destroyCollectionObjectForType:(NSString *)className identifier:(NSString *)identifier; @end // ==--==--==--==--==Notifications==--==--==--==--== extern NSString *const willDestroySingletonCollection; extern NSString *const willDestroySingletonCollectionObject; RMSingletonCollector.m // // RMSingletonCollector.m // RMSingletonCollector // // Created by Rich Meade-Miller on 2/11/11. // Copyright 2011 Rich Meade-Miller. All rights reserved. // #import "RMSingletonCollector.h" #import <objc/objc-runtime.h> NSString *const willDestroySingletonCollection = @"willDestroySingletonCollection"; NSString *const willDestroySingletonCollectionObject = @"willDestroySingletonCollectionObject"; RMInitializerData RMInitializerDataMake(SEL initializer, id data) { RMInitializerData newData; newData.designatedInitializer = initializer; newData.data = data; return newData; } @implementation NSObject (SingletonCollector) + (RMInitializerData)designatedInitializerForIdentifier:(NSString *)identifier { return RMInitializerDataMake(@selector(init), nil); } @end @interface RMSingletonCollector () + (NSMutableDictionary *)singletonCollection; + (void)setSingletonCollection:(NSMutableDictionary *)newSingletonCollection; @end @implementation RMSingletonCollector static NSMutableDictionary *singletonCollection = nil; + (NSMutableDictionary *)singletonCollection { if (singletonCollection != nil) { return singletonCollection; } NSMutableDictionary *collection = [[NSMutableDictionary alloc] initWithCapacity:1]; [self setSingletonCollection:collection]; [collection release]; return singletonCollection; } + (void)setSingletonCollection:(NSMutableDictionary *)newSingletonCollection { if (newSingletonCollection != singletonCollection) { [singletonCollection release]; singletonCollection = [newSingletonCollection retain]; } } + (id)collectionObjectForType:(NSString *)className identifier:(NSString *)identifier { id obj; NSString *key; if (identifier) { key = [className stringByAppendingFormat:@".%@", identifier]; } else { key = className; } if (obj = [[self singletonCollection] objectForKey:key]) { return obj; } // dynamic creation. // get a class for Class classForName = NSClassFromString(className); if (classForName) { obj = objc_msgSend(classForName, @selector(alloc)); // if the initializer takes an argument... RMInitializerData initializerData = [classForName designatedInitializerForIdentifier:identifier]; if (initializerData.data) { // pass it. obj = objc_msgSend(obj, initializerData.designatedInitializer, initializerData.data); } else { obj = objc_msgSend(obj, initializerData.designatedInitializer); } [singletonCollection setObject:obj forKey:key]; [obj release]; } else { // raise an exception if there is no class for the specified name. NSException *exception = [NSException exceptionWithName:@"com.RMDev.RMSingletonCollector.failed_to_find_class" reason:[NSString stringWithFormat:@"SingletonCollector couldn't find class for name: %@", [className description]] userInfo:nil]; [exception raise]; [exception release]; } return obj; } + (id<RMWeakObjectReference>)referenceForObjectOfType:(NSString *)className identifier:(NSString *)identifier { id obj = [self collectionObjectForType:className identifier:identifier]; RMWeakObjectRef *objectRef = [[RMWeakObjectRef alloc] initWithObject:obj identifier:identifier]; return [objectRef autorelease]; } + (void)destroyCollection { NSDictionary *userInfo = [singletonCollection copy]; [[NSNotificationCenter defaultCenter] postNotificationName:willDestroySingletonCollection object:self userInfo:userInfo]; [userInfo release]; // release the collection and set it to nil. [self setSingletonCollection:nil]; } + (void)destroyCollectionObjectForType:(NSString *)className identifier:(NSString *)identifier { NSString *key; if (identifier) { key = [className stringByAppendingFormat:@".%@", identifier]; } else { key = className; } [[NSNotificationCenter defaultCenter] postNotificationName:willDestroySingletonCollectionObject object:[singletonCollection objectForKey:key] userInfo:nil]; [singletonCollection removeObjectForKey:key]; } @end RMWeakObjectRef.h // // RMWeakObjectRef.h // RMSingletonCollector // // Created by Rich Meade-Miller on 2/12/11. // Copyright 2011 Rich Meade-Miller. All rights reserved. // // In order to offset the performance loss from always having to search the dictionary, I made a retainable, weak object reference class. #import <Foundation/Foundation.h> @protocol RMWeakObjectReference <NSObject> @property (nonatomic, assign, readonly) id objectRef; @property (nonatomic, retain, readonly) NSString *className; @property (nonatomic, retain, readonly) NSString *objectIdentifier; @end @interface RMWeakObjectRef : NSObject <RMWeakObjectReference> { id objectRef; NSString *className; NSString *objectIdentifier; } - (RMWeakObjectRef *)initWithObject:(id)object identifier:(NSString *)identifier; - (void)objectWillBeDestroyed:(NSNotification *)notification; @end RMWeakObjectRef.m // // RMWeakObjectRef.m // RMSingletonCollector // // Created by Rich Meade-Miller on 2/12/11. // Copyright 2011 Rich Meade-Miller. All rights reserved. // #import "RMWeakObjectRef.h" #import "RMSingletonCollector.h" @implementation RMWeakObjectRef @dynamic objectRef; @synthesize className, objectIdentifier; - (RMWeakObjectRef *)initWithObject:(id)object identifier:(NSString *)identifier { if (self = [super init]) { NSString *classNameForObject = NSStringFromClass([object class]); className = classNameForObject; objectIdentifier = identifier; objectRef = object; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(objectWillBeDestroyed:) name:willDestroySingletonCollectionObject object:object]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(objectWillBeDestroyed:) name:willDestroySingletonCollection object:[RMSingletonCollector class]]; } return self; } - (id)objectRef { if (objectRef) { return objectRef; } objectRef = [RMSingletonCollector collectionObjectForType:className identifier:objectIdentifier]; return objectRef; } - (void)objectWillBeDestroyed:(NSNotification *)notification { objectRef = nil; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [className release]; [super dealloc]; } @end

    Read the article

  • UIView animation doesn't work first time

    - by BobC
    Hello everybody, I have a seachButton in the navigation bar which upon hitting calls following method: - (IBAction)search:(id)sender { if (nil == searchViewController) searchViewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil]; searchViewController.view.backgroundColor = [UIColor clearColor]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:searchViewController.view cache:NO]; [self.view addSubview:searchViewController.view]; [UIView commitAnimations]; } It should load SearchViewController.xib which contains a view with UISearchBar and two buttons. When I call the search method for the first time, the view appears very quickly with some weird animation, when I call it again, the animation is alright. Does anyone have a clue what could be wrong?

    Read the article

  • Navigation Items in UITableViewController are not appearing?

    - by Sheehan Alam
    I am displaying a UITableViewController inside of a UITabBarController that is being presented modally: -(IBAction)arButtonClicked:(id)sender{ //this is a uitableviewcontroller ARViewController* arViewController = [[[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]autorelease]; LeaderBoardTableViewController* lbViewController = [[[LeaderBoardTableViewController alloc] initWithNibName:@"LeaderBoardTableViewController" bundle:nil]autorelease]; lbViewController.title = @"Leaderboard"; arTabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; arTabBarController.viewControllers = [NSArray arrayWithObjects:arViewController, lbViewController, nil]; arTabBarController.selectedViewController = arViewController; [self presentModalViewController:arTabBarController animated:YES]; } In my viewDidLoad for arViewController method I am setting the navigation items: - (void)viewDidLoad { [super viewDidLoad]; // Uncomment the following line to preserve selection between presentations. self.clearsSelectionOnViewWillAppear = NO; self.title = @"AR"; leaderBoardButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(leaderBoardButtonClicked:)]; self.navigationItem.rightBarButtonItem = leaderBoardButton; } My navigation bar doesn't appear when it is inside of the UITabBarController, but when I push the view itself I am able to see it. What am I missing?

    Read the article

  • random generator to obtain data from array not displaying

    - by Yang Jie Domodomo
    I know theres a better solution using arc4random (it's on my to-try-out-function list), but I wanted to try out using the rand() and stand(time(NULL)) function first. I've created a NSMutableArray and chuck it with 5 data. Testing out how many number it has was fine. But when I tried to use the button function to load the object it return me with object <sampleData: 0x9a2f0e0> - (IBAction)generateNumber:(id)sender { srand(time(NULL)); NSInteger number =rand()% ds.count ; label.text = [NSString stringWithFormat:@"object %@", [ds objectAtIndex:number] ]; NSLog(@"%@",label.text); } While I feel the main cause is the method itself, I've paste the rest of the code below just incase i made any error somewhere. ViewController.h #import <UIKit/UIKit.h> #import "sampleData.h" #import "sampleDataDAO.h" @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UILabel *label; @property (weak, nonatomic) IBOutlet UIButton *onHitMePressed; - (IBAction)generateNumber:(id)sender; @property(nonatomic, strong) sampleDataDAO *daoDS; @property(nonatomic, strong) NSMutableArray *ds; @end ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize label; @synthesize onHitMePressed; @synthesize daoDS,ds; - (void)viewDidLoad { [super viewDidLoad]; daoDS = [[sampleDataDAO alloc] init]; self.ds = daoDS.PopulateDataSource; // Do any additional setup after loading the view, typically from a nib. } - (void)viewDidUnload { [self setLabel:nil]; [self setOnHitMePressed:nil]; [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } - (IBAction)generateNumber:(id)sender { srand(time(NULL)); NSInteger number =rand()% ds.count ; label.text = [NSString stringWithFormat:@"object %@", [ds objectAtIndex:number] ]; NSLog(@"%@",label.text); } @end sampleData.h #import <Foundation/Foundation.h> @interface sampleData : NSObject @property (strong,nonatomic) NSString * object; @end sampleData.m #import "sampleData.h" @implementation sampleData @synthesize object; @end sampleDataDAO.h #import <Foundation/Foundation.h> #import "sampleData.h" @interface sampleDataDAO : NSObject @property(strong,nonatomic)NSMutableArray*someDataArray; -(NSMutableArray *)PopulateDataSource; @end sampleDataDAO.m #import "sampleDataDAO.h" @implementation sampleDataDAO @synthesize someDataArray; -(NSMutableArray *)PopulateDataSource { someDataArray = [[NSMutableArray alloc]init]; sampleData * myData = [[sampleData alloc]init]; myData.object= @"object 1"; [someDataArray addObject:myData]; myData=nil; myData = [[sampleData alloc] init]; myData.object= @"object 2"; [someDataArray addObject:myData]; myData=nil; myData = [[sampleData alloc] init]; myData.object= @"object 3"; [someDataArray addObject:myData]; myData=nil; myData = [[sampleData alloc] init]; myData.object= @"object 4"; [someDataArray addObject:myData]; myData=nil; myData = [[sampleData alloc] init]; myData.object= @"object 5"; [someDataArray addObject:myData]; myData=nil; return someDataArray; } @end

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >