Take the 2-minute tour ×

I'm trying to pass an image between 2 different views that are added as subclasses to the MainCanvasController. the image seems to get passed (it is shown, when printed to the Console) but it doesn't display anything... this is how I try to receive and display the image

    C4Log(@"number:%@", number);
    [self.canvas addImage:number];

    C4Log(@"received number: %@", receivedImage);


and here is how I post the image

[secondView receiveNumber:originalImage];

I don't really know what's going wrong. (well, honestly, I don't know at all...) So any hints are very much appreciated!

share|improve this question
Try this first: C4Image *newNumber = [number copy]; then change the center of the new number, then add the new number to the canvas. –  C4 - Travis Oct 24 '13 at 16:38
just tried. it doesn't make a difference –  suMi Oct 25 '13 at 8:39
I posted the code on GitHub in case you wanna have a look at the full thing: github.com/susemiessner/Urban-Alphabets/tree/master/… (did I say thanks for your constant help already?! It's amazing! thanks!) –  suMi Oct 25 '13 at 10:04
add comment

1 Answer

up vote 1 down vote accepted

I had a look at your project and found the answer.

Your FirstView object has a variable called secondView, which is exactly the same name as the object in your main workspace. However, despite having the same name both of these are different objects.

I've done a couple things:

1) instead of using variables in the interface file for your objects, use properties. 2) create a SecondView property in your FirstView class 3) set the property of firstView to the same object in your workspace, secondView

My FirstView.h looks like:

@interface FirstView : C4CanvasController{
    C4Label *goToSecondView;
@property (readwrite, strong) C4Window *mainCanvas;
@property (readwrite, strong) C4Image *postedImage;
@property (readwrite, strong) SecondView *secondView;

My postNoti: looks like:

    [self postNotification:@"changeToSecond"];
    [self.secondView receiveNumber:self.postedImage];

NOTE I got rid of the [SecondView new]; line.

The following is the part that you were missing

My workspace has the following line:

firstView.secondView = secondView;

Which sets the variable of the first view to have a reference to the secondView object.

You hadn't done this, and so you were passing the image to an object that had the same name as the view that's visible from your main workspace's canvas.

share|improve this answer
thanks!!! I'm learning new things in C4/objective C every day! (such as working with properties right now). –  suMi Oct 27 '13 at 9:14
Great! One of the core ideas behind C4 is that as you learn to work with it, you're also learning ObjC because the design of the API reflects the same patterns. –  C4 - Travis Oct 27 '13 at 19:11
add comment

Your Answer


