Image Browser images not replace second time when images inserted.

Discussion in 'Mac Programming' started by mkristain, Sep 9, 2011.

  1. mkristain macrumors regular

    Joined:
    Aug 18, 2011
    #1
    hello,

    i add the images with path and reloaddata to view the images.

    but second time the images are not changed and IKImageBrowserView display the previously loaded images, but when double click on item the correct image is open.

    so i found IKImageBrowserView not change the view of images when i inserted images again after removing previous images.

    please help me for this.

    thanks in advance.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    You're asking us to debug your code without seeing it.

    We can't read your mind.
    We can't see your files.

    Post your code.
     
  3. AGWright macrumors newbie

    Joined:
    Jun 28, 2010
    #3
    Have you cleared your array for the IKImageBrowerView
     
  4. mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011
    #4
    yes i removeallobject of image array but still i have the same problem.
    Code:
    //images is the image array
    
    [images removeAllObjects];
    images = [[NSMutableArray alloc] init];
    [imageBrowser reloadData];
    
    i use this when i m inserting images again in imagebrowser.

    please help me..
     
  5. JoshDC macrumors regular

    Joined:
    Apr 8, 2009
    #5
    The code you've posted doesn't help much at all. It doesn't look real world, and just shows you still don't understand memory management rules in Cocoa.

    The only advice I can think to give is that you're not properly using imageUID and/or imageVersion of the datasource items. This could cause the browser view to load from its cache.
     
  6. mkristain, Sep 10, 2011
    Last edited: Sep 10, 2011

    mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011
    #6
    yes the image name is same and i pass image name in imageUID so is this the main issue?

    please help me to resolve this.

    please tell me how can use imageVersion.

    thanks.
     
  7. JoshDC macrumors regular

    Joined:
    Apr 8, 2009
    #7
    Seems likely. imageVersion seems to exists for this purpose. Sounds like you just increment it each time the image is modified.
     
  8. mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011
    #8
    please can u give me any example for this.

    actually i am use this but now the image not display properly in image browser.

    Code:
    - (NSUInteger) imageVersion;
    {
    	image_version++;
    	
    	return image_version;
    }
    
    thanks.
     
  9. JoshDC macrumors regular

    Joined:
    Apr 8, 2009
    #9
  10. mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011
    #10
    this not works

    Code:
    - (NSString *) imageUID
    {
    	
    // This is uses the NSManagedObjectID for the entity to generate a unique string.
       return [[[self objectID] URIRepresentation] description];
    
    }
    
    so i am use this

    Code:
    - (NSString *) imageUID
    {
      return image_Name;
    }
    and When I call the following:
    
    [imageBrowserView reloadData];
    The Debugger Console prints this:
    
    --ImageKit Error: reloadData called in non main thread
    
    and some other error like jpeg data stream is corrupt if file contain not full image file.
    
    
    and vertical scroll not move down when images inserted.
    
    
     
  11. JoshDC macrumors regular

    Joined:
    Apr 8, 2009
    #11
    Copying and pasting without understanding is a really bad idea.

    I'm struggling to help you because you're giving very little useful information.

    For example:

    Code:
    --ImageKit Error: reloadData called in non main thread
    Is pretty explicit that you're not calling reloadData on the main thread. If you don't know how to do this then you shouldn't be messing around with threads in the first place.
     
  12. LostSoul80 macrumors 68020

    LostSoul80

    Joined:
    Jan 25, 2009
    #12
    I stopped reading the rest of the thread here.
    Have you read the documentation about NSMutableArray? Do you know what -removeAllObjects does? Have you read at least a part of Apple's memory management guide?
    Also, this is an English forum. Many of your statements are absolutely not clear.

    Being a developer implies you do your work -- reading and studying. Everyone can write two lines of codes, and that makes him/her no more than someone who typed two lines of code.

    Memory management: http://developer.apple.com/library/...onceptual/MemoryMgmt/Articles/MemoryMgmt.html

    NSMutableArray's documentation: http://developer.apple.com/library/...NSMutableArray_Class/Reference/Reference.html

    CFUUID documentation page: http://developer.apple.com/library/.../Reference/CFUUIDRef/Reference/reference.html


    Read those pages. Then, if you still have doubts, ask. But not before having read them.
     
  13. AGWright, Sep 10, 2011
    Last edited by a moderator: Sep 10, 2011

    AGWright macrumors newbie

    Joined:
    Jun 28, 2010
    #13
    Don't know why you are re-declairing the NSMutableArray called 'images'
    I'm using this

    Code:
    -(IBAction) SelectFolderWithImages:(id)sender
    {
        //Clear all MutableArrays ImportedImages, Images, FilteredOutImages]
       
        //Clear images and arrays
        [self ClearImages];
        //Load files from selected folder 
        [self loadImages];
       
    }
    
    -(void)ClearImages
    {
        [images removeAllObjects];
        [ImportedImages removeAllObjects];
        [images removeAllObjects];
        [filteredOutImages removeAllObjects];
        [filteredOutIndexes removeAllIndexes];
    }
    
    - (void)loadImages
    {
        NSArray *pathToSelectedFiles = openFiles();
        
        if(!pathToSelectedFiles)
        {
            NSLog(@"No path selected, return..."); 
            return;
        }
        [NSThread detachNewThreadSelector:@selector(addImagesWithPaths:) toTarget:self
                               withObject:pathToSelectedFiles];
        
        [ImageBrowser reloadData];
    }
    
     
  14. mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011

Share This Page