我有一个字典,用于存储使用参数名称的另一个字典.
我得到右侧不匹配错误.
这是我的代码
handle_cast({setState, Id}, State) ->
Id0 = dict:new(),
DQueue = queue:new(),
UQueue = queue:new(),
Id1 = dict:store(dQueue, [DQueue], Id0),
Id2 = dict:store(uQueue, [UQueue], Id1),
Id3 = dict:store(dSpeed, [], Id2),
Id4 = dict:store(uSpeed, [], Id3),
D = dict:store(Id, [Id4], State),
State = D,
{noreply, State};
Run Code Online (Sandbox Code Playgroud)
我不确定错误来自哪里.我想这可能是因为我将Id作为主词典中的键存储,新的内部词典作为值.
我需要内部字典的名称作为Id的值,因为它们将有很多,我需要稍后通过Id访问它们.
我是否正确设置了字典?erlang是否允许字典包含字典?
谢谢
我正在使用队列api并遇到了导致程序崩溃的错误.
首先,我从字典中获取队列,并在打印输出中返回该队列
获取的队列是[{[],[]}]
这是正常的吗?队列是否正确创建?
然后,当我尝试添加到队列或获取其长度时,我得到两个错误badargs.
TorrentDownloadQueue = dict:fetch(torrentDownloadQueue, State),
io:format("The fetched queue is ~p~n", [dict:fetch(torrentDownloadQueue, State)]),
% Add the item to the front of the queue (main torrent upload queue)
TorrentDownloadQueue2 = queue:in_r(Time, TorrentDownloadQueue),
% Get the lenght of the downloadQueue
TorrentDownloadQueueLength = queue:len(TorrentDownloadQueue2),
Run Code Online (Sandbox Code Playgroud)
当我尝试插入值10时,错误是
**终止原因==**{badarg,[{queue,in_r,[10,[{[],[]}]]},{ph_speed_calculator,handle_cast,2},{gen_server,handle_msg,5},{ proc_lib,init_p_do_apply,3}]}**异常退出:函数队列中的badarg:in_r/2称为队列:in_r(10,[{[],[]}])来自ph_speed_calculator的调用:handle_cast/2 in call from gen_server:从proc_lib调用handle_msg/5:init_p_do_apply/3 13>
这是in_r的错误,但我也得到了len调用的badargs错误.
我称之为或者初始队列不正确的方式有什么问题?我按如下方式创建队列并将其添加到字典中
TorrentDownloadQueue = queue:new(),
TorrentUploadQueue = queue:new(),
D4 = dict:store(torrentDownloadQueue, [TorrentDownloadQueue], D3),
D5 = dict:store(torrentUploadQueue, [TorrentUploadQueue], D4),
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么.
我有很多类,并希望在他们的UIImageViews中添加一个UIGestureRecognizer.
我正确地为所有类添加一个.事情是我重复代码,以便每个类添加相同的识别器.这些是本地识别者
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget : self action : @selector (handleSingleTap:)];
[singleTap setNumberOfTapsRequired:1];
[background addGestureRecognizer:singleTap];
[singleTap release];
Run Code Online (Sandbox Code Playgroud)
所以它应该仍适用于每个班级.
问题是它只适用于第一类,而不适用于其他类.
background是UIImageView,存在于每个类中.所以我有多个背景.
我提出了每个新的ModelViewController类,这可能是什么问题?
我使用识别器如下
- (void) handleSingleTap : (UIGestureRecognizer*) sender
{
//do whatever
}
Run Code Online (Sandbox Code Playgroud)
每个类也实现了
@interface Someclass : UIViewController <UIGestureRecognizerDelegate>
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它不起作用.我在每个handleSingleTap方法中打印出来.什么都没打印出来
如果在使用char数组之前需要声明它,那么如何声明一个char数组以便可以用来存储输入?
例如,用户输入一个句子或一系列单词.如何存储以便可以操作?
什么是正确的方法而不是仅仅声明一个足以处理预期输入的数组?
在不知道数组中存储的最终结构数量的情况下,如何在C中创建结构数组?
我想在for循环中循环,创建一个tempStruct设置其变量,将其添加到数组然后再循环,创建一个新的tempStruct并将其添加到数组中.
我有一些问题包围着我在C中如何做到这一点,同时试图从客观C.
我有一个视图,将新视图推送到屏幕上.
显示新视图时,导航控制器中没有后退按钮.
我在一个视图中有以下内容
然后使用以下代码推送新视图
[photoViewController setAsset:[assets objectAtIndex:(cell.rowNumber * 4) + index]];
[[self navigationController] pushViewController:photoViewController animated:YES];
[photoViewController release];
Run Code Online (Sandbox Code Playgroud)
当视图出现时,可以看到以下内容

如何添加后退按钮以及在第二个视图中将相同的共享按钮添加到栏的位置?
谢谢.:)
如何在目标c中为整数或NSUIntegers创建数组?
问题是我想要一个我可以经常更改的数组(NSMutableArray?)但是当我尝试添加对象时:someInt或someNSUInteger我得到一个关于"没有强制转换"的警告,当代码执行应用程序崩溃时.
设置它的最快方法是什么?我不知道阵列的大小.它应该是动态的.
我一直在使用Textmate编写我的C源代码,但希望通过终端完成所有工作.
一个程序如何通过终端?是否需要安装其他任何东西?
c ×4
iphone ×3
erlang ×2
arrays ×1
char ×1
dictionary ×1
macos ×1
objective-c ×1
queue ×1
struct ×1
terminal ×1
user-input ×1