Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

ios - Very simple iPhone App crashes on UILabel settext -


i have simple application. have button , label in ib. have ibaction onclick calls settext on label. there's outlet label. connected in ib. crashes app first time in simulator. when launch again, sets text. crashes again next time. crashes on actual device. should simple, i'm not sure i'm doing wrong.

thanks.

in .h file :

#import <uikit/uikit.h>  @interface untitledviewcontroller : uiviewcontroller { iboutlet uilabel *label; iboutlet uibutton *button; }  @property (nonatomic, retain) uilabel *label;  -(ibaction) onclick1: (id) sender;  @end 

and in .m:

- (ibaction) onclick1: (id) sender {     //[label settext:@"hello world!"];     label.text = @"hello world!";     //[button settitle:@"clicked" forstate:uicontrolstatenormal]; } 

sorry, i'm new site. how crash log , stack? thanks.

edit : while answer technically correct, doesn't answer question @ :( sorry


< warning - guess >

if you're getting crash setting label's text tells me have set value label in past it's not been retained correctly.

i'm guessing have code :

label = [[[uilabel alloc] initwithframe:cgrectmake(0,0,10,10)] autorelease]; 

when should have code like

// option 1 self.label = [[[uilabel alloc] initwithframe:cgrectmake(0,0,10,10)] autorelease]; 

or

// option 2 label = [[uilabel alloc] initwithframe:cgrectmake(0,0,10,10)]; 

( first 1 uses property retain label. second 1 doesn't autorelease it. first 1 recommended way )


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -