Search Results

Search found 3754 results on 151 pages for 'ios simulator'.

Page 74/151 | < Previous Page | 70 71 72 73 74 75 76 77 78 79 80 81  | Next Page >

  • sqlite 3 opening issue

    - by anonymous
    I'm getting my data ,with several similar methods, from sqlite3 file like in following code: -(NSMutableArray *) getCountersByID:(NSString *) championID{ NSMutableArray *arrayOfCounters; arrayOfCounters = [[NSMutableArray alloc] init]; @try { NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *databasePath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"DatabaseCounters.sqlite"]; BOOL success = [fileManager fileExistsAtPath:databasePath]; if (!success) { NSLog(@"cannot connect to Database! at filepath %@",databasePath); } else{ NSLog (@"SUCCESS getCountersByID!!"); } if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK){ NSString *tempString = [NSString stringWithFormat:@"SELECT COUNTER_ID FROM COUNTERS WHERE CHAMPION_ID = %@",championID]; const char *sql = [tempString cStringUsingEncoding:NSASCIIStringEncoding]; sqlite3_stmt *sqlStatement; int ret = sqlite3_prepare(database, sql, -1, &sqlStatement, NULL); if (ret != SQLITE_OK) { NSLog(@"Error calling sqlite3_prepare: %d", ret); } if(sqlite3_prepare_v2(database, sql, -1, &sqlStatement, NULL) == SQLITE_OK){ while (sqlite3_step(sqlStatement)==SQLITE_ROW) { counterList *CounterList = [[counterList alloc]init]; CounterList.counterID = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,0)]; [arrayOfCounters addObject:CounterList]; } } else{ NSLog(@"problem with database prepare"); } sqlite3_finalize(sqlStatement); } else{ NSLog(@"problem with database openning %s",sqlite3_errmsg(database)); } } @catch (NSException *exception){ NSLog(@"An exception occured: %@", [exception reason]); } @finally{ sqlite3_close(database); return arrayOfCounters; } //end } then i'm getting access to data with this and other similar lines of code: myCounterList *MyCounterList = [[myCounterList alloc] init]; countersTempArray = [MyCounterList getCountersByID:"2"]; [countersArray addObject:[NSString stringWithFormat:@"%@",(((counterList *) [countersTempArray objectAtIndex:i]).counterID)]]; I'm getting a lot of data like image name and showing combination of them that depends on users input with such code: UIImage *tempImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_0.jpg",[countersArray objectAtIndex:0]]]; [championSelection setBackgroundImage:tempImage forState:UIControlStateNormal]; My problem: When i'm run my app for some time and get a lot of data it throws error: " problem with database openning unable to open database file - error = 24 (Too many open files)" My guess is that i'm opening my database every time when getCountersByID is called but not closing it. My question: Am i using right approach to open and close database that i use? Similar questions that have not helped me to solve this problem: unable to open database Sqlite Opening Error : Unable to open database UPDATE: I made assumption that error is showing up because i use this lines of code too much: NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *databasePath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"DatabaseCounters.sqlite"]; BOOL success = [fileManager fileExistsAtPath:databasePath]; and ending up with error 24. So i made them global but sqlite3_errmsg shows same err 24, but app runs much faster now I'll try to debug my app, see what happens

    Read the article

  • How to set only the first cell of a UITableView to a different color?

    - by Ted
    I use cellForRowAtIndexPath like here: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil) cell = [self getCellContentView:CellIdentifier]; UILabel *lbl = (UILabel*)[cell.contentView viewWithTag:1]; for (UITableViewCell *c in [tbl visibleCells]) { // UITableViewCell *cell2 = [tbl cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]; UILabel *lbl = (UILabel*)[c.contentView viewWithTag:1]; lbl.textColor = [UIColor redColor]; } if([tbl indexPathForCell:cell].section==0) lbl.textColor = [UIColor whiteColor]; UILabel *lblTemp1 = (UILabel *)[cell viewWithTag:1]; UILabel *lblTemp2 = (UILabel *)[cell viewWithTag:2]; //First get the dictionary object lblTemp1.text = @"test!"; lblTemp2.text = @"testing more"; NSLog(@"%@",[tbl indexPathForCell:cell]); return cell; } But is still makes some of my cells white instead of gray. How can I change only the first item in the row to white?

    Read the article

  • Call IBAction in other method

    - by user1628083
    I have an IBAction of SignIn and Method getData. When load it call SignIn into method Getdata in case I want auto sign in without click button Sign In. -(void)getData {       if ([_remCheckbox state] == NSOnState)     {         NSUserDefaults *store = [NSUserDefaults standardUserDefaults];                  NSString *un = [store objectForKey:@"usrname"];         NSString *pw = [store objectForKey:@"usrpwd"];                  _txtUsername.stringValue = un;         _txtPwd.stringValue = pw;                  //call event IBAction              }   } - (IBAction)buttonSignIn:(id)sender {     //Signin code suppose to work fine }

    Read the article

  • plus minus table View cell

    - by user1748387
    I have the following code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UIImage * i1 = [UIImage imageNamed: @"inc_01.png"]; UIImage * i2 = [UIImage imageNamed: @"inc_02.png"]; UIImage * i3 = [UIImage imageNamed: @"inc_04.png"]; UIImage * i5 = [UIImage imageNamed: @"inc_05.png"]; UIImage * i6 = [UIImage imageNamed: @"inc_06.png"]; UIImage * i7 = [UIImage imageNamed: @"inchd.png"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } if(indexPath.row == 0) { UIImageView * header= [[UIImageView alloc] initWithImage: i1]; cell.backgroundView = header; // Configure the cell… } else if (indexPath.row == 2) { UIImageView *backgroundCellImage=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 280, 11)]; backgroundCellImage.image=[UIImage imageNamed:@"inc_06.png"]; [cell.contentView addSubview:backgroundCellImage]; } else { // Configure the cell… UIImageView *imageView = [[UIImageView alloc] initWithImage: i3]; cell.textLabel.text = @"text"; UIImageView *backgroundCellImage=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 57, 46)]; backgroundCellImage.image=[UIImage imageNamed:@"inc_02.png"]; UIImageView *backgroundCellImage2=[[UIImageView alloc] initWithFrame:CGRectMake(223, 0, 57, 46)]; backgroundCellImage2.image=[UIImage imageNamed:@"inc_04.png"]; UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(57, 0, 166, 46)]; label.text = @"wow"; [cell.contentView addSubview:backgroundCellImage]; [cell.contentView addSubview:backgroundCellImage2]; [cell.contentView addSubview:label]; } return cell; } that basically creates a table view and puts an image to the left and right of each cell. I want it so that people can click on the left or right image in each cell, and something different happens based on the cell number. So if they click on the left image for cell in row 1, a function gets call with the row number they clicked on, and an indicator telling me they clicked on the left image and not the right image. How can I do that using objective-c?

    Read the article

  • Content Alignment Issue in UITableView cell

    - by OhhMee
    Please see the image attached. I don't understand why it's going outside. I've also attached code snippet for tableView. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; // cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; } // Configure the cell. hNode* dCell = [array objectAtIndex:[indexPath row]]; cell.textLabel.text = @"Message"; cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",[dCell contents]]; cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap; cell.detailTextLabel.numberOfLines = 0; [[cell imageView] setImage:[UIImage imageNamed:@"user.png"]]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath { return 60; } Where could be the issue?

    Read the article

  • How to upload a file with JQueryMobile for an iphone/ipad?

    - by JD
    Hi, I have just started looking at JqueryMobile and want to know if the following is possible? I want to be able to select a file (similar to in html) and then show some sort of dialogue that allows me to browse to a "folder" and select the file. It would then be up to me to send some sort of AJAX command to upload it to the server (where I am using Asp.net MVC 2) Since I do not have access to an iPhone or iPad, I was told that I would only have access to the documents folder. JD

    Read the article

  • How to compare 2 button title using index or tag value

    - by fasil moham
    Here my application i having set of button 12 buttons,button titles are hidden by default.Button titles are shown when it is clikced , -(IBAction)buttonAction:(id)sender { UIButton *button = (UIButton *)sender; int index = button.tag; [self showing:index]; //now, this method accepts a parameter. } -(void) showing:(NSInteger)index { UIButton* btn = nil; index = index - 1; NSArray* subViewArray = [self.view subviews]; NSInteger i = 0; for (UIView *view in subViewArray) { if ([view isKindOfClass:[UIButton class]]) { btn = (UIButton*) view; NSString* text; if (i == index) { text = [self.textArray objectAtIndex:i]; //put the array that you are using self.previousButtonTag = i; //make a class variable }else { text = @""; } i++; [btn setTitle:text forState:UIControlStateNormal]; } } } 1.I want to compare two button title values to check whether it is equal or not.Im facing the problem , 2.Only press button title only visible,when i click other button previous title is hided,I want to enable two button title on click and wen it is wrong it should be hided.Please suggest me the How to solve this issue,Please do the needfully

    Read the article

  • UITableView headings shown on top of MBProgressHUD

    - by Chris Ballinger
    So I have a subclass of UITableViewController that loads some data from the internet and uses MBProgressHUD during the loading process. I use the standard MBProgressHUD initialization. HUD = [[MBProgressHUD alloc] initWithView:self.view]; [self.view addSubview:HUD]; HUD.delegate = self; HUD.labelText = @"Loading"; [HUD show:YES]; This is the result: . Is there any way to resolve this issue, or should I just abandon MBProgressHUD? Thanks!

    Read the article

  • Storyboard changing controller (modal) not working

    - by BrandNew
    I have problem with navigation between ViewControllers: here is my storyboard: http://postimg.org/image/dar9pkuvl/ The navigation between controllers in green rectangle works fine, I add to controller number 1 controller number 2 (by addtosubview) and then controllers number 3,4,5 to UIScrollView in controller number 2 ( controller number 2 contain scrollview). Everything work fine but if I click Send buttn on controller 4 nothing happens (It is strange because I was added connection between button and controller in the same way like between controllers 7 and 8). I know it is little bit confusing described, but I hope that someone tell me where is problem. Thanks

    Read the article

  • Iphone app getting crashing when i enter the iphone mail sheet

    - by Gopinath
    In my iphone app. I'm Creating Iphone Mail Chat Sheet using MFMailComposeViewController. Now when I enter the second time,the mail sheet, my app is getting crashed. I searched in Google. But I couldn't find the solution. Anybody help me to solve my issue. PLease see this below code and help me where am I doing wrong. if ([MFMailComposeViewController canSendMail]) { controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; [controller setSubject:@""]; [controller setToRecipients:array1]; [controller setMessageBody:@"" isHTML:NO]; [controller setMailComposeDelegate: self]; [controller setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; [self.navigationController presentModalViewController:controller animated:NO]; [controller release]; } - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { if(result == MFMailComposeResultSent) { [[self parentViewController] dismissModalViewControllerAnimated:YES]; } else if (result == MFMailComposeResultCancelled) { [[self parentViewController] dismissModalViewControllerAnimated:YES]; } }

    Read the article

  • How to call a method after asynchronous task is complete

    - by doctordoder
    I have a class called WikiWebView which is a subclass of UIWebView which loads Wikipedia subjects and is designed to fetch all the links of the webpage, in order to create a sort of site map for the subject. My problem is that I can only create the links once the web page has loaded, but the loading isn't done right after [self loadRequest:requestObj] is called. - (void)loadSubject:(NSString *)subject { // load the actual webpage NSString *wiki = @"http://www.wikipedia.org/wiki/"; NSString *fullURL = [wiki stringByAppendingString:subject]; NSURL *url = [NSURL URLWithString:fullURL]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [self loadRequest:requestObj]; // [self createLinks]; // need this to be called after the view has loaded } - (void)createLinks { NSString *javascript = @"var string = \"\";" "var arr = document.getElementsByClassName(\"mw-redirect\");" "for (var i = 0; i < arr.length; ++i)" "{" "var redirectLink = arr[i].href;" "string = string + redirectLink + \" \";" "}" "string;"; NSString *links = [self stringByEvaluatingJavaScriptFromString:javascript]; self.links = [links componentsSeparatedByString:@" "]; } I tried the normal delegation technique, which lead to this code being added: - (id)init { if (self = [super init]) { self.delegate = self; // weird } return self; } #pragma mark - UIWebViewDelegate - (void)webViewDidStartLoad:(UIWebView *)webView { ++_numProcesses; } - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { --_numProcesses; } - (void)webViewDidFinishLoad:(UIWebView *)webView { --_numProcesses; if (_numProcesses == 0) { [self createLinks]; } } However, the delegate methods are never called.. I've seen similar questions where the answers are to use blocks, but how would I do that in this case?

    Read the article

  • UITableViewController executes delate functions before network request finishes

    - by user1543132
    I'm having trouble trying to populate a UITableView with the results of a network request. It seems that my code is alright as it works perfectly when my network is speedy, however, when it's not, the function - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath- still executes, which results in a bad access error. I presume that this is because the array that the aforesaid function attempts to utilize has not been populated. This brings me to my question: Is there anyway that I can have the UITableView delegate methods delayed to avoid this? - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"AlbumsCell"; //UITableViewCell *basicCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; AlbumsCell *cell = (AlbumsCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (!cell) { **// Here is where the Thread 1: EXC_BAD_ACCESS (code=2 address=0x8)** cell = [[[AlbumsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } Album *album = [_albums objectAtIndex:[indexPath row]]; [cell setAlbum:album]; return cell; }

    Read the article

  • Facebook og:image

    - by Roderick Standaart
    So i have a problem with the facebook og:image. site: http://images.vallo-app.com/4db279b31df280b/ if people use this link to show their image, its no problem, facebook loads the og:image But it is used in an iPhone App, so people make a picture and get a shortened url of bit.ly back and then they can post it. So if you post it, facebook juts doesn't show the preview of the image, but if you post that shortened bit.ly link on facebook.com in the statusupdate it does. Someone know what the problem is?

    Read the article

  • UISearchBarDisplayController - Fixed SearchBar

    - by slik
    I've been trying to get UISearchBarDisplayController to not animate, and stay fixed below the navigation bar. Is this even possible, I've been getting some weird results. This is all configured through a storyboard. I am just trying to figure out If I should just create my own implementation of UISearchBarDisplayController since it kinda seems a little impossible to customize it to my need. Clicking the search box When I start searching the top has extra paddding (20pt). It's assuming its on top of the origin y: 0 to prevent overlapping of status bar. I can't click outside or the cancel, x buttons. What happens If I click cancel, before searching

    Read the article

  • Portrait video to landscape

    - by dappa
    I am aware questions like this one may already be out there but for the sake of others like me I will go ahead and ask I have a app that is set to only allow portrait orientation but this setting affects my videos as I would like only the videos to be able to play in landscape also. Is there a method I can add unto my .m file to make this work? Here is my code; #import "BIDVideosViewController.h" @interface BIDVideosViewController () @end @implementation BIDVideosViewController @synthesize moviePlayer ; @synthesize tableList; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; UITableView *table = [[UITableView alloc]initWithFrame:self.view.bounds]; [table setDelegate:self]; [table setDataSource:self]; [self.view addSubview:table]; tableList = [[NSMutableArray alloc] initWithObjects:@"Gangan",@"SwimGood",@"German Ice", nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [tableList count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *DisclosureButtonIdentifier = @"DisclosurebutotonIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DisclosureButtonIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DisclosureButtonIdentifier]; } NSInteger row = [indexPath row]; NSString *rowString = [tableList objectAtIndex:row]; cell.textLabel.text = rowString; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { { NSBundle *str = [tableList objectAtIndex:indexPath.row]; if ([str isEqual:@"Gangan"]) { NSBundle *bundle = [NSBundle mainBundle]; NSString *thePath = [bundle pathForResource:@"Gangan" ofType:@"mp4"]; NSURL *theurl = [NSURL fileURLWithPath:thePath]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl]; [moviePlayer setMovieSourceType:MPMovieSourceTypeFile]; [self.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES]; [moviePlayer play]; } else if ([str isEqual:@"SwimGood"]) { NSBundle *bundle = [NSBundle mainBundle]; NSString *thePath = [bundle pathForResource:@"SwimGood" ofType:@"mp4"]; NSURL *theurl = [NSURL fileURLWithPath:thePath]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl]; [moviePlayer setMovieSourceType:MPMovieSourceTypeFile]; [self.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES]; [moviePlayer play]; } else if ([str isEqual:@"German Ice"]) { NSBundle *bundle = [NSBundle mainBundle]; NSString *thePath = [bundle pathForResource:@"German Ice" ofType:@"mp4"]; NSURL *theurl = [NSURL fileURLWithPath:thePath]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl]; [moviePlayer setMovieSourceType:MPMovieSourceTypeFile]; [self.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES]; [moviePlayer play]; } } } @end

    Read the article

  • Can't give my custom prototype cells in tableview different heights

    - by kerbelda
    I've looked around at other questions here and many other sources online and just can't find a solution. I have 3 rows and no matter what I do, they all keep the width defined in the tableview. The first one is what I want, but the second and 3rd I can't give a custom height. Below is my code: #import "DetailTableViewController.h" #import "EventDetailTableViewCell.h" #import "EventDescriptionTableViewCell.h" #import "EventMapTableViewCell.h" @interface DetailTableViewController () @end @implementation DetailTableViewController - (void)viewDidLoad { [super viewDidLoad]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 3; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { static NSString *CellIdentifier = @"headerCell"; EventDetailTableViewCell *headerCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; headerCell.headerImage.image = [UIImage imageNamed:@"img4.png"]; return headerCell; } else if (indexPath.section == 1) { static NSString *CellIdentifier = @"descriptionCell"; EventDescriptionTableViewCell *descriptionCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; descriptionCell.descriptionImage.image = [UIImage imageNamed:@"img2.png"]; return descriptionCell; } else { static NSString *CellIdentifier = @"mapCell"; EventMapTableViewCell *mapCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; return mapCell; } } #pragma mark - Helper Methods - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (section == 1) { return @" "; } else if (section == 2) { return @" "; } else { return nil; } } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) { return 222; } else if (indexPath.row == 1) { return 80; } else { return 100; } } @end

    Read the article

  • Drawing animation

    - by HHHH
    I'm creating a simple app where when the user presses a button, a series of lines will be drawn on the screen and the user will be able to see these lines drawn in real time (almost like an animation). My code looks something like this (has been simplified): UIGraphicsBeginImageContext(CGSizeMake(300,300)); CGContextRef context = UIGraphicsGetCurrentContext(); for (int i = 0; i < 100; i++ ) { CGContextMoveToPoint(context, i, i); CGContextAddLineToPoint(context, i+20, i+20); CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]); CGContextStrokePath(context); } UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); My problem is that: 1) As soon as the user presses the button, the UIThread blocks until the drawing is done. 2) I can't get the lines to be drawn on the screen one at a time - I've tried setting the UIImage directly inside the loop and also tried setting a layer content inside the loop. How do I get around these problems?

    Read the article

  • Store data in tableview to NSUserDefaults

    - by Jozef Vrana
    Tricks.h file #import "Tricks.h" @implementation Tricks static NSMutableArray *trickList = nil; +(NSMutableArray *)trickList { if(!trickList){ trickList = [[NSMutableArray alloc]init]; } return trickList; } @end Tricks.m file @interface Tricks : NSObject @property(strong, nonatomic) NSString *trickName; Method for adding objects to array -(IBAction)saveAction:(id)sender { Tricks *trick = [[Tricks alloc]init]; trick.trickName = self.trickLabel.text; [[Tricks trickList]insertObject:trick atIndex:0]; [self.navigationController popViewControllerAnimated:YES]; } In .h file of UITabelview class I am making a reference to tricks class, but I am sure there is error on this line. @property (strong, nonatomic) Tricks *tricks; In cellForRow method I am storing data _trick = [[NSMutableDictionary alloc]initWithObjectsAndKeys:trick,nil]; NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults]; [defaults setObject:_trick forKey:@"numberArray"]; [defaults synchronize]; NSLog(@"%@",_trick); In .m class of UITableview in viewDidLoad I want to retrieve data if([[NSUserDefaults standardUserDefaults] objectForKey:@"numberArray"] != nil) { _tricks = [[NSUserDefaults standardUserDefaults] objectForKey:@"numberArray"]; } Thanks for advices

    Read the article

  • MVC design pattern in complex iPad app: is one fat controller acceptable?

    - by nutsmuggler
    I am building a complex iPad application; think of it as a scrapbook. For the purpose of this question, let's consider a page with two images over it. My main view displays my doc data rendered as a single UIImage; this because I need to do some global manipulation over them. This is my DisplayView. When editing I need to instantiate an EditorView with my two images as subviews; this way I can interact with a single image, (rotate it, scale it, move it). When editing is triggered, I hide my DisplayView and show my EditorView. In a iPhone app, I'd associate each main view (that is, a view filling the screen) to a view controller. The problem is here there is just one view controller; I've considered passing the EditorView via a modal view controller, but it's not an option (there a complex layout with a mask covering everything and palettes over it; rebuilding it in the EditorView would create duplicate code). Presently the EditorView incorporates some logic (loads data from the model, invokes some subviews for fine editing, saves data back to the model); EditorView subviews also incorporate some logic (I manipulate images and pass them back to the main EditorView). I feel this logic belongs more to a controller. On the other hand, I am not sure making my only view controller so fat a good idea. What is the best, cocoa-ish implementation of such a class structure? Feel free to ask for clarifications. Cheers.

    Read the article

  • How to do something when AVQueuePlayer finishes the last playeritem

    - by user1634529
    I've got an AVQueuePlayer which I'm creating from an array of 4 AVPlayerItems, and it all plays fine. I want to do something when the last item in the queue finishes playing, I've looked a load of answers on here and this is the one that looks most promising for what I want: The best way to execute code AFTER a sound has finished playing In my button handler i have this code: static const NSString *ItemStatusContext; [thePlayerItemA addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd) name:AVPlayerItemDidPlayToEndTimeNotification object:thePlayerItemA]; theQueuePlayer = [AVQueuePlayer playerWithPlayerItem:thePlayerItemA]; [theQueuePlayer play]; and then I have a function to handle playerItemDidReachEnd: - (void)playerItemDidReachEnd:(NSNotification *)notification { // Do stuff here NSLog(@"IT REACHED THE END"); } But when I run this I get an Internal Inconsistency Exception: An -observeValueForKeyPath:ofObject:change:context: message was received but not handled. Key path: status Observed object: <AVPlayerItem: 0x735a130, asset = <AVURLAsset: 0x73559c0, URL = file://localhost/Users/mike/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/A0DBEC13-2DA6-4887-B29D-B43A78E173B8/Phonics%2001.app/yes.mp3>> Change: { kind = 1; } What am I doing wrong?

    Read the article

  • InApp subscriptions - trasferability

    - by meap
    Apple has rejected one of our apps, where the user can purchase content through subscriptions (InApp product type is subscription). The problem is that we need to, also because of Apple requiring it, these subscriptions to be transferable between devices. The logical and also the most secure solution would be to link it to a user account, that the user will have to create. But this was the reason why apple rejected this app. They have told us that for purchasing of subscriptions a registration can not be required, can be only optional. So the question is how to solve this if there is no other nice solution that would make sense, be secure and still comfortable for the user?

    Read the article

  • How to set UITableViewCell highlighted image

    - by SmartTree
    I want to launch a method every time when user just highlights a cell (doesn't select it) in UITableView. Could you tell me please, how is it possible to do this ? I want to do it because I have a custom cell with a pictures on it and I want to change pictures every time when user highlights the cell. UPD: By highlight I mean that user just highlights a cell and don't release the finger from it. By select I mean when didSelectRowAtIndexPath is being launched (so the user releases the finger from the cell after he presses on it)

    Read the article

  • Pass Variables In Inheritance (Obj - C)

    - by Marmik Shah
    I working on a project in Obj-C where i have a base class (ViewController) and a Derived Class (MultiPlayer). Now i have declared certain variables and properties in the base class. My properties are getting accessed from the derived class but im not able to access the variables (int,char and bool type). I'm completely new to Obj-C so i have no clue whats wrong. I have used the data types which are used in C and C++. Is there some specific way to declare variables in Obj-C?? If so, How? Here are my files ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (weak,nonatomic) IBOutlet UIImageView* backGroungImage; @property (strong,nonatomic) IBOutlet UIImageView *blockView1; @property (strong,nonatomic) IBOutlet UIImageView *blockView2; @property (strong,nonatomic) IBOutlet UIImageView *blockView3; @property (strong,nonatomic) IBOutlet UIImageView *blockView4; @property (strong,nonatomic) IBOutlet UIImageView *blockView5; @property (strong,nonatomic) IBOutlet UIImageView *blockView6; @property (strong,nonatomic) IBOutlet UIImageView *blockView7; @property (strong,nonatomic) IBOutlet UIImageView *blockView8; @property (strong,nonatomic) IBOutlet UIImageView *blockView9; @property (strong,nonatomic) UIImage *x; @property (strong,nonatomic) UIImage *O; @property (strong,nonatomic) IBOutlet UIImageView* back1; @property (strong,nonatomic) IBOutlet UIImageView* back2; @end ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController int chooseTheBackground = 0; int movesToDecideXorO = 0; int winningArrayX[3]; int winningArrayO[3]; int blocksTotal[9] = {8,3,4,1,5,9,6,7,2}; int checkIfContentInBlocks[9] = {0,0,0,0,0,0,0,0,0}; char determineContentInBlocks[9] = {' ',' ',' ',' ',' ',' ',' ',' ',' '}; bool player1Win = false; bool player2Win = false; bool playerWin = false; bool computerWin = false; - (void)viewDidLoad { [super viewDidLoad]; if(chooseTheBackground==0) { UIImage* backImage = [UIImage imageNamed:@"MainBack1.png"]; _backGroungImage.image=backImage; } if(chooseTheBackground==1) { UIImage* backImage = [UIImage imageNamed:@"MainBack2.png"]; _backGroungImage.image=backImage; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end I am not able to use the above declared variables in my derived classes!

    Read the article

  • MKPinAnnotationView - hard to drag

    - by James Zaghini
    I have a MKPinAnnotationView that the user can drag around the map. It is very difficult for a user to drag the pin. I've tried increasing the frame size and also using a giant custom image. But nothing seems to actually change the hit area for the drag to be larger than default. Consequently, I have to attempt to tap/drag about ten times before anything happens. MKPinAnnotationView *annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"bluedot"] autorelease]; UIImage *image = [UIImage imageNamed:@"blue_dot.png"]; annView.image = image; annView.draggable = YES; annView.selected = YES; return annView; What am I missing here?

    Read the article

  • iPhone - Adding new sections and rows into UITableView

    - by Dev
    I have a UITableView to display a list of data. The list will contain images, so I am loading images with lazy loading. Now I don't want to load the whole list at a time. The loading should be like, first it should load some 10 records and when we scrolling down to the tableview, it should automatically load next 10 records as on. For this I need to add rows when I am scrolling to bottom. The tableview may contain different sections. So how can I add new rows and new sections at the end of the tableview while scrolling down?

    Read the article

< Previous Page | 70 71 72 73 74 75 76 77 78 79 80 81  | Next Page >