我将从一个例子中解释我的问题.
在.H文件中//
@interface Employee:NSObject{
@private
NSString *name;
}
@property(nonatomic,retain) NSString *name;
Run Code Online (Sandbox Code Playgroud)
在.M文件中//
@implementation{
@synthesize name;
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,当我访问另一个类中的name属性时,myEmp.Name = @"John";
它不会引起任何问题.这是根据封装规则还是我的误解?
前几天我正在阅读ChanL的来源.它包含一个使用渠道的例子来实现期货.DEFUN在LET中声明,如下:
(let ((some-var some-value))
(defun foo () ... (reference some-var) ... )
(defun bar () ...))
Run Code Online (Sandbox Code Playgroud)
这有什么用途?它只是提供一些共同的价值,几个功能可以共享,并保持封装清洁?
任何人都可以告诉我[\x09-\x0d -~]以下签名的含义.我所熟悉的正则表达式,但这个签名是在C代码,我不明白是什么这意味着x和~,我试图做的签名,我在java中工作,我已经看到了这一点x,并~多次在网,但我无法理解它是什么意思.这些正则表达式或这些是十六进制值还是其他什么?因为我还没有在正则表达式和SIP消息中看到过这种情况.
^(invite|register|cancel|message|subscribe|notify) sip[\x09-\x0d -~]*sip/[0-2]\.[0-9]
Run Code Online (Sandbox Code Playgroud) 我将开始学习如何Smalltalk提高我的面向对象技能.哪种Smalltalk实现最能满足我的目的.如果可能,我在哪里可以找到材料来学习推荐的实施.
PS 1:不,请不要建议跳过学习Smalltalk和使用C#或Java的想法.
PS 2:如果你认为还有其他更好的方法来提高我的OOP技能.这些是什么?
我是Macintosh上的Ruby开发人员.
谢谢
所以我正在开发一个程序,该程序应该"堆积"用户添加到集合中的整数等等.但是,当我尝试访问作为参数传递给函数的Node的左子节点时,我现在遇到了问题.Visual Works耗尽内存......
奇怪的是,在调试器中,我可以看到传递节点的Left子节点已创建并正确分配给传递的节点.但是当我尝试通过源代码访问它时,我得到一个疯狂的内存错误.
这是相应的代码.希望它是可读的
一旦被调用,就会发生错误的函数:
addLeftChildTo: aNode
"Determine Left child of passed node. Set that child's parent node as self. Imprint the index where that value was retrieved from the array."
| temp leftChildIndex |
2 * aNode indexOfNode <= arrayOfInput size
ifTrue:
[leftChildIndex := 2 * aNode indexOfNode.
aNode left: (arrayOfInput at: leftChildIndex).
aNode left parentNode: aNode. <---VW Runs out of memory and crashes here. This occurs once the debugger dives into the 'left' accessor method of the passed …Run Code Online (Sandbox Code Playgroud) 例如,如果背景为白色,则文本颜色将为黑色。如果BG为黑色,则文本为白色。蓝色BG,黄色文本等。 更新:
// method in MyActivity class
void changeBackgroundColor(int newColor) {
activityLayout.setBackgroundColor(newColor);
int invertingColor = ColorInvertor.invert(newColor);
someTextView.setTextColor(invertingColor);
}
Run Code Online (Sandbox Code Playgroud)
如果我致电activity.changeBackgroundColor(Color.WHITE),则someTextView必须将文本颜色更改为黑色,即ColorInvertor.invert(Color.WHITE) == Color.BLACK,ColorInvertor.invert(Color.BLACK) == Color.WHITE等等。
我正在编写一个需要用户处于安静环境中的应用程序.为此,我会定期检查麦克风的电源读数.(我知道返回的值是dBFS,或者在这种情况下,在[0,1]区间内是浮点数.)
我的问题是下面的代码工作得很好......除非它返回18466064732283753157623808.00000.我看不到NSLog输出指示AudioQueueGetProperty返回失败.奇怪的值始终是提到的值.
-(float)instantaneousPeakPower {
UInt32 dataSize = sizeof(AudioQueueLevelMeterState) * recordFormat.mChannelsPerFrame;
AudioQueueLevelMeterState *levels = (AudioQueueLevelMeterState*)malloc(dataSize);
OSStatus rc = AudioQueueGetProperty(audioQueue, kAudioQueueProperty_CurrentLevelMeter, levels, &dataSize);
if (rc) {
NSLog(@"NoiseLeveMeter>>takeSample - AudioQueueGetProperty(CurrentLevelMeter) returned %@", rc);
}
float channelAvg = 0;
for (int i = 0; i < recordFormat.mChannelsPerFrame; i++) {
channelAvg += levels[i].mPeakPower;
}
free(levels);
// This works because in this particular case one channel always has an mAveragePower of 0.
return channelAvg;
}
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?值的位模式是否可能提供线索?
这是Squeak 4.1中的除法方法:
/t1
| t2 |
t1 isInteger
ifTrue: [t2 := self digitDiv: t1 abs neg: self negative ~~ t1 negative.
(t2 at: 2)
= 0
ifTrue: [^ (t2 at: 1) normalize].
^ (Fraction numerator: self denominator: t1) reduced].
^ t1 adaptToInteger: self andSend: #/
Run Code Online (Sandbox Code Playgroud)
我不懂代码.你能给我一些关于如何调试代码的提示,所以我可以跟踪代码行为吗?就像打开工作区一样,键入4/3,我可以检查分数.有自己的对象,分子,分母等.我怎样才能进入4/3,看看Smalltalk如何实现除法?
我基本上在遗留系统上工作,遗留代码是用Smalltalk语言编写的,并试图将Smalltalk中的一些方法转换为Java中的等效方法名.这些是Smalltalk中一些名为的类的方法名称Grid.我不熟悉Smalltalk语法.Java中相应的名称是什么?方法签名是什么样的?
at: cell put: dataforeColor: color1 backColor: color2 cell: cell我想在我的网站两侧加阴影,你可以在这里看到 - http://www.oztrik.sk/wp-content/uploads/2012/01/trik.jpg
我想将它们放入左右的divs带width:100%;和height:auto; 背景图像,repeat-y.
#left { background:url('../img/shadow_left.png') left center repeat-y; width:100%; height:auto; float:left; }
#right { background:url('../img/shadow_right.png') right center repeat-y; width:100%; height:auto; float:right; }
Run Code Online (Sandbox Code Playgroud)
问题是当width内容div大于浏览器窗口大小时,阴影会停留在窗口的右侧而不是页面的右侧.当我把它放到时auto,问题又回来了.
此外,当页面缩小时,阴影以内容的结尾结束.
任何想法如何解决?谢谢!
我已经声明了一个enum数据类型:
typedef enum TagTypes
{
BUTTON_TAG_1 = 1,
BUTTON_TAG_2,
BUTTON_TAG_3,
NEW_TAG
}ButtonTag;
typedef enum TagType
{
LABEL_TAG_1 = 1,
LABEL_TAG_2,
NEW_TAG
}LabelTag;
Run Code Online (Sandbox Code Playgroud)
我希望通过此标记值找到按钮或标签的相应标记
(clickedbutton.tag == ButtonTag.BUTTON_TAG1) 要么 (changingLabel.tag == LabelTag.LABEL_TAG_1)
但是这个语法在Obj C中似乎不可能,它会引发错误,说出预期的标识符或")"
有没有办法可以通过指定tagDatatype来选择tagNames:
LabelTag.LABEL_TAG_2, ButtonTag.BUTTON_TAG2, ...
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助
clickedbutton.tag == BUTTON_TAG1会起作用,但我更喜欢像tagName.tagValue一样使用它,这样我就可以在不同的标签集中使用相同的tagValues,在LabelTag和ButtonTag中都使用tagValue"NEW_TAG".
我是android开发的初学者.现在我试图通过emulator.MS SQL 2008 R2在另一台(服务器)机器上运行来连接MS SQL 2008 R2.我收到以下错误:
The TCP/IP connection to the host xxx.xxx.xx.x\SQL2008R2DEV has failed;
error: null;
verify connection properties.
make sure that instance of SQL server running on the host and accepting TCP/IP connection to the port are not blocked by Windows Firewall.
Run Code Online (Sandbox Code Playgroud)
注意我在java应用程序中完成了这个.我也可以访问我的数据库.但为什么不能在android程序中?有什么想法吗?
注意:两台服务器和我的PC都通过LAN连接.
smalltalk ×4
android ×2
iphone ×2
java ×2
objective-c ×2
binary-heap ×1
c ×1
common-lisp ×1
css ×1
delphi ×1
enums ×1
html ×1
ipad ×1
oop ×1
regex ×1
ruby ×1
sql-server ×1
squeak ×1
web-scraping ×1