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.

Objective-C creating a dynamic bidimensional array -


i'm trying create class can manage bidimensional array. used same algorithm in c without objects (obviously) , works fine. problem when try modify variable of object doesn't modify in main program, , absurd!

nsmatrice.h

#import <cocoa/cocoa.h> #import <foundation/foundation.h>  struct ogmat {     float value;     int row, col;     struct ogmat *next; };  typedef struct ogmat tmat; typedef tmat* tptmat;  @interface nsmatrice : nsobject{     tptmat m; } - (void)    crea;       //inizializza la matrice - (int)     destroy;    //la distrugge - (bool)    exisistsatxy :(int) x :(int) y; - (void)    setvalueatxy :(float) value :(int) x :(int) y; - (float)   getvalueatxy :(int) x :(int) y;  @end 

nsmatrice.c

#import "nsmatrice.h" @implementation nsmatrice - (void)    crea{       //inizializza la matrice     m=null; } - (int)     destroy{    //la distrugge     while (m!=null){         tptmat pa;         pa=m->next;         free(m);         m=null;         m=pa;     }     return 1; } - (bool)    exisistsatxy :(int) x :(int) y{     while (m!=null&&(!(m->col==y&&m->row==x))){         m=m->next;     }     if (m==null) return false;     else return true; } - (void)    setvalueatxy :(float) value :(int) x :(int) y{     tmat *pa;     if (!([self exisistsatxy:x:y])){//nuova testa modifico pa         pa=malloc(sizeof(tmat));         pa->col=y;         pa->row=x;         pa->value=value;         pa->next=m;         m=pa;     }else{         pa=m;         while (pa!=null&&(!(pa->col==y&&pa->row==x))){//stessa testa             pa=pa->next;         }         if (pa!=null){             pa->value=value;         }     } } - (float)   getvalueatxy :(int) x :(int) y{     tmat *pa;     pa=m;     while (pa!=null&&(!(pa->col==y&&pa->row==x))){         pa=pa->next;     }     if (pa!=null){         return pa->value;     }     else return 0; } @end 

obj_mat.m

#import <foundation/foundation.h> #import "nsmatrice.h" #import <time.h>  int main () {     nsmatrice *m;     int i,j;     m=[nsmatrice alloc];     [m crea];     srand(time(null));     (i=0;i<5;i++)         (j=0;j<5;j++)             [m setvalueatxy:rand()%20 :i :j];     (i=0;i<5;i++){         (j=0;j<5;j++)             printf("%.2f\t",[m getvalueatxy:i :j]);         printf("\n");     } } 

i suspect got exisistsatxy method - changes link in list m addresses, rather making copy of pointer , using traverse - in setvalueatxy method.


Comments

Popular posts from this blog

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

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

ios - Very simple iPhone App crashes on UILabel settext -