Note that there are some explanatory texts on larger screens.

plurals
  1. PO[__NSArrayM objectAtIndex:]: index 197 beyond bounds [0 .. 8]
    primarykey
    data
    text
    <p>I have product table in database. Product table i have id &amp; product_image column. Each image having id. I'm getting these id from database and taken to cat_imageidArray, Then getting images &amp; taken to productimg_array. Assign the productimg_array image value to imgView1 (UIButton). I'm using [productimg_array objectAtIndex:i]. Here index is 0 to 7 or etc. But cat_imageidArray having value of 183,184,190 etc. When i click imgView1 button i'm getting these error [__NSArrayM objectAtIndex:]: index 197 beyond bounds [0 .. 8]. I understood the problem is array value is not matching. How to assign the cat_imageidArray value to productimg_array index. Maybe then it will work.</p> <pre><code>const char *sql = "SELECT id,cat_id,product_image,order_by,description FROM product where cat_id = ?"; NSLog(@"sql is %s",sql); sqlite3_stmt *statement; if (sqlite3_prepare_v2(database, sql, -1, &amp;statement, NULL) == SQLITE_OK) { // We "step" through the results - once for each row. if (sqlite3_bind_int(statement, 1, categoryId) != SQLITE_OK) NSLog(@"%s: bind failed: %s", __FUNCTION__, sqlite3_errmsg(database)); while (sqlite3_step(statement) == SQLITE_ROW) { cat_iamgeId = sqlite3_column_int(statement, 0); NSLog(@"cat_iamgeId is %ld",(long)cat_iamgeId); [cat_imageidArray addObject:@(cat_iamgeId)]; product_image = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 2)]; NSLog(@"product_image is %@",product_image); [productimg_array addObject:product_image]; } } for (int i = 0; i&lt;[productimg_array count]; i++ ) { NSLog(@"productimg_array_index %@", productimg_array[i]); imgView1=[[UIButton alloc]initWithFrame:CGRectMake(20+(i*74), 0, 72, 72)]; Width = Width + 20+(i*74); for (int i=0; i&lt;[cat_imageidArray count]; i++){ NSLog(@"index %@", cat_imageidArray[i]); tag=[[cat_imageidArray objectAtIndex:i]intValue]; imgView1.tag=tag; NSLog(@"tag is %d",tag); } [imgView1 addTarget:self action:@selector(dbsofaClicked:) forControlEvents:UIControlEventTouchUpInside]; [imgView1 setImageWithURL:[NSURL URLWithString:[productimg_array objectAtIndex:i]]forState:UIControlStateNormal]; [scrollview addSubview:imgView1]; } imgView1 button click: -(void)dbsofaClicked:(id)sender{ NSLog(@"button %d is clicked.", [sender tag]); mmageView=[[UIImageView alloc]initWithFrame:CGRectMake(50,50,150,150)]; [mmageView setUserInteractionEnabled:YES]; [mmageView setImageWithURL:[NSURL URLWithString:[productimg_array objectAtIndex:[sender tag]]] placeholderImage:nil options:SDWebImageProgressiveDownload completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { }]; </code></pre> <p>NSLog productimg_array:</p> <pre><code>productimg_array ( "http://center.net/projects/View/images/img.png", "http://center.net/projects/View/images/img1.png", "http://center.net/projects/View/images/img2.png", "http://center.net/projects/View/images/img3.png", "http://center.net/projects/View/images/img4.png", "http://center.net/projects/View/images/img5.png", "http://center.net/projects/View/images/img6.png", "http://center.net/projects/View/images/img7.png", "http://center.net/projects/View/images/img8.png" ) </code></pre> <p>When i use singleTap the image i didn't get correct description from database value. that's why i need to set id instead of index</p> <pre><code>- (void)singleTap:(UIGestureRecognizer *)singletap { NSLog(@"singleTap1"); UIView *view = singletap.view; switch (view.tag) { case 0: txtt=[[UITextView alloc]initWithFrame:CGRectMake(50, 100, 200, 100)]; txtt.text=[descript_array objectAtIndex:0]; txtt.editable=NO; NSLog(@"text is %@",txtt.text); [self.view addSubview:txtt]; break; case 1: txtt1=[[UITextView alloc]initWithFrame:CGRectMake(50, 100, 200, 100)]; txtt1.text=[descript_array objectAtIndex:1]; NSLog(@"text1 is %@",txtt1.text); [self.view addSubview:txtt1]; break; case 2: txtt2=[[UITextView alloc]initWithFrame:CGRectMake(50, 100, 200, 100)]; txtt2.text=[descript_array objectAtIndex:2]; NSLog(@"text2 is %@",txtt2.text); [self.view addSubview:txtt2]; break; case 3: txtt3=[[UITextView alloc]initWithFrame:CGRectMake(50, 100, 200, 100)]; txtt3.text=[descript_array objectAtIndex:3]; NSLog(@"text is %@",txtt3.text); [self.view addSubview:txtt3]; break; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload