Posts

How to use OCMock to return different result base on different argument -

i trying mock different method return when passing different argument same method. self.mymock = [ocmockobject mockforclass:[myclass class]]; [[[self.mymock expect] andreturnvalue:5] mystaticmethod:3]; [[[self.mymock expect] andreturnvalue:10] mystaticmethod:6]; but takes first one, when argument 3 return 5, , when argument 6, return nil instead of 10. know whether way test this? the real code: -(nsmutablearray*)convertchildstringtochilddic:(nsstring*)strchildren { nsarray *kididarray = [strchildren componentsseparatedbystring:@","]; //处理小孩信息 /*children = ( { avatarsmall = "<null>"; currentstatus = 0; displayname = stu1; "id_str" = "70938032-3811-e411-946a-005056c00008"; title = child; } )*/ nsmutablearray *rstchildarray = [nsmutablearray arraywithcapacity:1]; (nsstring *enrollment_id in kididarray) { if (enrollment_id.length <= 0) { ...

ios - Cells do not show up in my tableview -

i new swift / xcode. stuck, have created struct sectionname, sectionobject, , section image. believe code correct, when run simulator not populate tableview cells have created. cell type basic, , identifier cell. there no errors besides yellow triangle says "initialization of immutable value 'objectarray' never used; consider replacing assignment '_' or removing it" around object array variable when run code, doesn't call of tableview func 's . i have removed of content in objectarray ,and replaced them "xxxxx" make easier. i must missing , here code : class "classname" : uiviewcontroller, uitableviewdelegate, uitableviewdatasource { struct objects { var sectionname : string! var sectionobjects : [string]! var sectionimage : [uiimage]! } var objectarray = [objects]() @iboutlet weak var "myname"tableview: uitableview! override func viewdidload() { super.viewdidload() let objecta...

c# - How to make sure a loop within a task has run at least once -

let's have class called scheduler contains dictionary of <userid, task> , task continuously loops , updates internal dictionary schedules user <userid, schedule> information database i.e. want keep information updated in real time. i want have method on scheduler class getscheduleforuser checks see if there task user , if not it'll create task wait til finishes , retrieves schedules user (lazy load it). my question is, after first iteration of task i'll have schedule available , can retrieve schedule...no problem first iteration need wait until task finished @ least 1 time before retrieving schedule. i can start task , create while loop until flag set when it's finished first time loop seems me there better way , it'll useful first iteration. afterwards schedule available , won't need functionality. does have clean way accomplish this? the best solution can think of use taskcompletionsource , eser mentioned in comment. here...

angularjs - John Papa's Angular Style Guide Y165 Recommendation... what to inject in app.core module? -

in y165 , john papa recommends injecting cross app modules app.core. angular.module('app.core', [angular modules, 'nganimate', 'ngsanitize', cross-app modules, 3rd party modules]); however, in other examples, manually injects needs in own module... i.e. dataservice.$inject = ['$http']; $http common one, i'm thinking injecting app.core. bad idea? i'm little confused, inject app.core , how determine whether should injected manually or if should injected app.core? (i.e. there unspoken rule put app.core if 2+ modules share it? 3+ modules?)

c# - want to move each array from arrayList into int [ ] -

there 350 elements in arraylist , each of consist of array of 9 integers i-e count of each element 9 . want retrievere each of it. here trying giving me error "unable cast object of type 'system.collections.generic.list`1[system.int32]' type 'system.int32[]'." filename = "e:\\normalized_sheet1.txt"; filestream fs = file.openread(filename); streamreader sr = new streamreader(fs); while (!sr.endofstream) { line = sr.readline().split('\t'); //make array of text each time list<string> arr = new list<string>(); arr.addrange(line); list<int> intlist = arr.convertall(s => int32.parse(s)); myvalues.add(intlist); } sr.close(); fs.close(); (i = 0; < samples; i++) { inputparameter=(int[]) myvalues[i]; // error } myvalues.add(intlist.toarray()); because mentioned have list of arrays . if it's list<int[]> can't add lists - can add arrays. toarray() retu...

configure route to page that is in subfolder rails -

i have design.html.erb file in folder views/services/ how configure route page in routes.rb ? (i have controller static pages called static_pages_controller don't need backend actions) need this: '/services/design' => 'static_pages#what_to_write_here' get '/services/design' => 'static_pages#design' this render design.html.erb inside views/static_pages/ directory. in order specify view in sub-folder have specify in action: def design render 'services/design' end this render design.html.erb inside views/services/ directory.

Change date and time format via command prompt -

i wondering, in windows 7 , above, possible change way dates , times displayed via command prompt? yes, i'm in u.s. doing things european way: (in clock/language/region) short date: set "d/m/yyyy" long date: set "dddd, d mmmm yyyy" short time: set "hh:mm" long time: set "hh:mm:ss" yes, it's possible e.g. using reg add command . check hkey_current_user\control panel\international registry key: reg query "hkcu\control panel\international" for instance, query short time format: reg query "hkcu\control panel\international" /v sshorttime and set desired value: reg add "hkcu\control panel\international" /v sshorttime /t reg_sz /d hh:mm /f if value name or data contains spaces, use double quotes (surrounding double quotes not written registry): reg add "hkcu\control panel\international" /v sshorttime /t reg_sz /d "hh:mm" /f