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 - What is the difference between valueforKey:, objectForKey:, and valueForKeyPath:? -


i have 2 questions:

  1. what difference between valueforkey: , objectforkey:? 1 nsdictionarys (objectforkey:) , others valueforkey:, or reverse?

  2. also difference between valueforkey: , valueforkeypath:? has got core data?

please help.

valueforkey: part of nskeyvaluecoding protocol , therefore part of key-value coding framework, allows access class properties name @ runtime. that's how nibs loaded, example — names of properties associated connections loaded , values set directly name. contrasts way visual interface design tools work in other languages, generating lots of hidden statically compiled code.

objectforkey: defined on dictionaries only, , looks object key. nsdictionary class stores connections between values , keys.

so, valueforkey: used on nsdictionary return meta information dictionary, such count of objects inside it, list of keys, etc. objectforkey: used dictionary.

at runtime, difference objectforkey: method opaque implementation. valueforkey: explicitly relies on subsequently calling named getters , setters. reason latter can extend key-value coding key-value observing, ask informed every time particular property on particular object changes. @ runtime that's achieved method swizzle, original setter replaced new 1 calls previous setter , sends out required messages. because messages dispatched dynamically, that's achieved modifying tables within object instance.

so object key-value coding compliant (which means declaring , implementing properties in proper way, new-ish @property/@synthesize syntax automatically) can observed without object having implement code.

there's further apple stuff uses key-value coding achieve various things, including coredata, it's not enable 1 other technology.

valueforkeypath: valueforkey: except can traverse several objects. can have root object bunch of properties, each of properties object bunch of properties, etc, , using key path can retrieve value way out @ leaf of data structure rather having iterate through object after object yourself.

in summary, valueforkey: , valueforkeypath: provide information object instances , interact dynamic nature of objective-c runtime. objectforkey: dictionary specific method dictionary tasks.

additions:

an example, coded type , assuming nsdictionary key-value coding compliant:

nsdictionary *somedictionary; // create somedictionary, populate it, example (note: assume photoofkeys.jpg // exists, not idea production code — if doesn't we'll // nil there , after won't added dictionary it'll appear // terminated list): somedictionary = @{ @"favouritegarment": @"hat",                     @"@allkeys"        : [nsimage imagenamed:nsimagenamedotmac],                     @(2)               : nsarray.new };  nsobject *allkeys;  // make no assumptions type @allkeys be,  going assume // can nslog it, needs descendant of nsobject rather 'id'  // respond 'description' message — compile // time semantics, if else reads code it'll make obvious them  // thinking...  // code of keys stored in dictionary , print them out; // should print array containing strings 'favouritegarment', '@allkeys' , // number 2 allkeys = [somedictionary valueforkey:@"@allkeys"]; nslog(@"%@", allkeys);  // code object named '@allkeys' dictionary; print // description of image created loading photoofkeys.jpg, above allkeys = [somedictionary objectforkey:@"@allkeys"]; nslog(@"%@", allkeys); // `objectforkey analogous `objectforkeyedsubscript:`, aka allkeys = somedictionary[@"@allkeys"]; 

allkeys property of nsdictionary described here. i've added mapping nsstring allkeys photograph of keys. whether use key-value coding valueforkey: methods or nsdictionary objectforkey: lookup method dictates whether read property of object instance or whether send object instance message asking unique job.


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 -