我从"reflect"包中的函数调用中获取此返回值:
< map[string]string Value >.
想知道我是否可以访问返回值内的实际地图,如果是,如何?
编辑:
所以这就是我正在进行返回Value对象的调用.它返回[< map[string]string Value >]到我抓取该数组中的第一个对象.但是,我不确定如何转换[< map[string]string Value >]为常规地图.
view_args := reflect.ValueOf(&controller_ref).MethodByName(action_name).Call(in)
Run Code Online (Sandbox Code Playgroud) 我的代码最后一个问题涉及到反射包中的.Call函数.
所以我正在打这样的电话:
params := "some map[string][]string"
in := make([]reflect.Value,0)
return_values := reflect.ValueOf(&controller_ref).MethodByName(action_name).Call(in)
Run Code Online (Sandbox Code Playgroud)
我正在制作.Call的方法如下:
func (c *Controller) Root(params map[string][]string) map[string] string{}
Run Code Online (Sandbox Code Playgroud)
我不太明白的是如何操纵"in"变量以便将我需要的地图正确传递到函数中.我看到make()中的第二个参数是参数的长度?但我不太明白如何格式化变量以正确传递我的参数.我递归地运行错误消息:
reflect: Call with too few input arguments
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激!
我只是没有得到这里发生的事情.
我有一个UITableView,其中每个单元格包含一些子视图,它工作正常.不幸的是,性能是可怕的,滚动太过于波涛汹涌.我读过,也许你可以继承UITableViewCell,这可能有助于提高性能,但我不确定如何实现或实现另一个解决问题的解决方案.我已经发布了下面的tableView的委托方法,任何帮助将不胜感激!
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UIImageView* imageView;
UILabel* ttitle;
UILabel* ttitle2;
UILabel* ttitle3;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
// Configure cell:
// *** This section should configure the cell to a state independent of
// whatever row or section the cell is in, since it is only executed
// once when the cell is first created.
imageView=[[UIImageView alloc]initWithFrame:CGRectMake(10.0, 11.0, …Run Code Online (Sandbox Code Playgroud) go ×2
reflection ×2
function ×1
go-reflect ×1
ios ×1
parameters ×1
subview ×1
uitableview ×1
xcode ×1