NSArray into QCview

itsthejayj's picture

Obj C is current making me feel like a toddler swimming in the deep sea!

What i'm trying to do is pass a NSMutableArray of images from an Xcode image browser example into a qcview. That is possible right!?

I'm using setValue:NSMutableArray forInputKey

Everything seem to work as i can see the correct structure count displayed within qcview, however I'm getting the below error when trying to display the images in qcview

<QCOpenGLPort_Image = 0x7ff743d95100 "inputImage" | owner = <QCSprite = 0x7ff743d93cd0 "Sprite_2"> | object = (null)> could not take value from <QCVirtualPort = 0x7ff743d921e0 "outputMember" | owner = <QCStructureMember "index" = 0x7ff743d91af0 "StructureMember_index_1">> = <myImageObject: 0x7ff7468033d0>

My simple Xcode example is on attachment, could some please have a look and direct me in my error of way, I really have so much to learn when it comes to Obj C and QC

Thanks

J

PreviewAttachmentSize
ImageBrowser.zip78.88 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cybero's picture
double post phenomena

double post phenomena

cybero's picture
Re: NSArray into QCview

The application you are seeking to make only shows the structure count when one runs it via Xcode, it does not evidence any feedback, even though receipting images, unless one runs it as a Run build from Xcode.

I don't think the image object knows what's what and this shows when running the compiled application without Xcode running and instigating the application via the Xcode run button.

itsthejayj's picture
Re: NSArray into QCview

@cybero Oh that weird, builds seem to be working on different user accounts on my end ! *im such a newbie with all this. Add and remove images and the structure count does go up and down with my current build. I just need to work out how to change the format of a Array for qc to read?

The problem is on two accounts... one) i don't know what i'm doing, two) i should know what i'm doing!

If i attempt to talk like i know what i'm doing, i'm pretty sure I need to convert the NSMutableArray into a NSDictionary.

It would be so useful to have an example of an IKImageBrowserView passing it images into a qcview

PreviewAttachmentSize
ImageBrowser.app_.zip34.29 KB

dust's picture
Re: NSArray into QCview

you can send both NSArray NSMutableArray and NSDicitionary to qc. I prefer to work with NSMutable as they are mutable. Your projects image is of type myImageObject which inherits from id or in your case NSObject. QC doesn't have a virtual port for NSObjects however your myImageObject uses a imageUID as an absolute file path identifier which QC does have a type for. Seeing your image object is just a file path you can simply pass a new array to qc with the imageUID as an NSString id and use the image importer to load it up in qc.... to do this you need your array which you have named "qcimageArray" although first you need to change its type to NSMutableArray so we can add and remove objects from it.

your variable will look like this in .h file

NSMutableArray *qcimageArray;

next make a property for it. this will make an auto get and set for you.

@property (nonatomic , retain ) NSMutableArray *qcimageArray;

then you need to synthesize this property so you can use it like so... in .m under implementation.

@synthesize qcimageArray;

you also need to release the object when your done with it so it doesn't leak... in your dealloc method.

    [qcimageArray release];

once that is done in your awake from nib method instantiate your array buy initializing it with an arbitrary number. i choose ten it doesn't matter the array is mutable.

 qcimageArray = [[NSMutableArray alloc]initWithCapacity:10];

now lastly when you update your data source you want to update the qc array as well. so when you update your data source you want to remove all the objects currently in your qc array and add the new set based on your original image array.

 [qcimageArray removeAllObjects];
 
    for (int i = 0; i < [_images count]; i++) {
 
        [qcimageArray insertObject:[[_images objectAtIndex:i] imageUID] atIndex:i];
 
    }
 
    [_qcImageview setValue:qcimageArray forInputKey:@"image_stru"];

the reason you get this error

<QCOpenGLPort_Image = 0x7ff743d95100 "inputImage" | owner = <QCSprite = 0x7ff743d93cd0 "Sprite_2"> | object = (null)> could not take value from <QCVirtualPort = 0x7ff743d921e0 "outputMember" | owner = <QCStructureMember "index" = 0x7ff743d91af0 "StructureMember_index_1">> = <myImageObject: 0x7ff7468033d0>

is because you where connecting the original image to an image port of a sprite. your original image isn't not an NSImage it is and NSObject therefore QC doesn't know how to compute that.

PreviewAttachmentSize
ImageBrowser-3.zip103.28 KB

cybero's picture
Re: NSArray into QCview

Very useful explanation of the naming and calling of NS objects, dust.

I think that itsthejayj might well have been wanting to have his old composition in situe as your revamp loses the textual feedback , though that swap around is quite easily done.

Actually I think it's a mixture of the two that's required, as yours does lay out the images in the QCView panel.

That said, the resulting application, in both itsthejayj's original post and your carefully coded exemplar loses the feedback QCView panel when expanding the application window or going to full screen. The image browser covers up the QCView panel on the right hand side.

itsthejayj's picture
Re: NSArray into QCview

Excellent help there dust as per usual! Got the cogs flowing nicely my end. I'm having a love hate relationship with obj c at the moment, but with your continuous guidance i'm getting there!

However am I correct in thinking there is no way to get the images out of an IKImageBrowser into a qcview. Using paths creates an annoying loading process!!!!

itsthejayj's picture
Re: NSArray into QCview

Oh yeah if anyone is interested in my last few hours worth of playing with all this, check out the attachment with the Xcode project.

PreviewAttachmentSize
ImageBrowser.zip1 MB

dust's picture
Re: NSArray into QCview

yes its possible to send qc an array of images. basically you use the path to create an image and add that to the array the same way. this way qc doesn't have to deal with the image downloading loading process.

[qcimageArray removeAllObjects];
    NSImage *image;
 
    for (int i = 0; i < [_images count]; i++) {
        image = [Bad link];
        [qcimageArray insertObject:image atIndex:i];
   }
 
    [_qcImageview setValue:qcimageArray forInputKey:@"image_stru"];
    [image release];
PreviewAttachmentSize
ImageBrowser-4.zip103.42 KB

cybero's picture
Re: NSArray into QCview

Nice one.