insert subview to a UIView


hi,
i'm writing ipad app school, , make custom view controller controls navigation of user. made switchviewcontroller class , added self.window in app delegate. then, in interface builder, added view controller. added view uiimage background. added smaller view (583 x 964). made iboutlet uiview, named mainview. in switchviewcontroller file, added these lines viewdidload:

code:
grades_iphone *tempgrades = [[grades_iphone alloc] initwithnibname:@"grades_ipad" bundle:nil];      grades = tempgrades;      [tempgrades release];      [self.mainview insertsubview:grades.view atindex:0];
when tried run it, xcode gave me "exc_bad_access" on line [self.mainview insertsubview:grades.view atindex:0]; . however, when use 1 of apple's provided template navigation (for example, tabbarcontroller), there no problem. please me out!
 

(use code tags on code)

exc_bad_access means invalid pointer (nil, released, or otherwise bogus).

code snippet posted begs bunch of questions:
a) grades , defined?
b) mainview , defined?
c) values of self.mainview , grades when exception raised?

last answer best determined using debugger , setting breakpoint @ line of code going fail.
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Has to be the funniest headline ive ever seen

Man Brings Goat to Apple Store and has Pizza Delivered

Elusive Ninja: The Shadowy Thief - Can you survive the fast-paced ninja chaos?