Program Quit iOS

Discussion in 'iOS Programming' started by oxcug, Nov 23, 2011.

  1. oxcug macrumors newbie

    Joined:
    Oct 3, 2011
    #1
    Hey guys, when I run my program i get this message in the console:
    Code:
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setText:]: unrecognized selector sent to instance 0x1baef0'
    *** First throw call stack:
    (0x339c28bf 0x350de1e5 0x339c5acb 0x339c4945 0x3391f680 0x35693 0x34a687ff 0x34a74c39 0x34a74aa9 0x34a7498f 0x34a74211 0x34a73f53 0x34a68673 0x34a68349 0x3391c435 0x34a4a9eb 0x34a4a9a7 0x34a4a985 0x34a4a6f5 0x34a4b02d 0x34a4950f 0x34a48f01 0x34a2f4ed 0x34a2ed2d 0x35559df3 0x33996553 0x339964f5 0x33995343 0x339184dd 0x339183a5 0x35558fcd 0x34a5d743 0x2381 0x2318)
    terminate called throwing an exception
    And then of course it quits the program. Anybody know how to stop it from quiting?
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    TADAAA, if you read the message, it actually says, what you are trying to do, and from reading that, you should know, you have an imageview, and you are trying to set text on it, which it doesn't have as property, so it will crash.
    If you fix that, it will run.
     
  3. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #3
    Stop trying to send setText: to an UIImageView? UIImageView doesn't have a setText method or a text property.

    -----
    Simultaneous post with jnoxx! LOL.
     
  4. oxcug thread starter macrumors newbie

    Joined:
    Oct 3, 2011
    #4
    Thanks, I'll keep lookin for that

    Thanks guys, I actually already saw that and was looking for a "setText" call on a UIImage but couldn't find one (written by me). So I'll keep lookin for it.

    THANKS!
     
  5. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #5
    Do you have something like obj.text = @"Blah" somewhere?
     
  6. oxcug thread starter macrumors newbie

    Joined:
    Oct 3, 2011
    #6
    Yeah but they're labels not UIImages. I just went through all my code making sure non of them were accidently images.
     
  7. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #7
    We're not talking about UIImages but UIImageViews.

    Are you sure they're UIImageViews? If you log the actual class of your objects what do you get?

    You can log the actual class of an object in the variable obj with something like this?
    Code:
    NSLog(@"obj class = %@", NSStringFromClass([obj class]));
    
     
  8. oxcug thread starter macrumors newbie

    Joined:
    Oct 3, 2011
    #8
    I think i figured out the problem (please tell me if this would do the trick)

    fancyImage is a property.
    my Code looks like this (i'm setting the image):
    Code:
    self.fancyImage.image = [UIImage imageNamed:@"mypic.png"];
    BUT it should look like:
    Code:
    [self.fancyImage setImage:[UIImage imageNamed:@"mypic.png"]];
    is that right?
     
  9. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #9
    They're equivalent. The compiler effectively turns the first into the second. So changing it won't solve your bug.
     
  10. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #10
    Like Jiminaus said.
    synthesizing your property, only generates getters/setters.
    The Point notation vs the setObject notation is only a difference between different versions of Objective-C.
    So it should result in the same.
    Try setting breakpoints, see where your code stops/crashes, and you will know what's wrong. Maybe you are setting labels, but accidently setting the pointer of a label to an UIImageView.
    So just debug via breakpoints and head back.
     
  11. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
  12. oxcug thread starter macrumors newbie

    Joined:
    Oct 3, 2011
    #12
    Alright thanks everyone! I thought the problem was in my code but it was actually in my connections in my .xib/storyboard file. I was connecting a label with a UIImageView. (No clue how that happened):confused:. Anyways thanks to all!
     

Share This Page