我正在尝试更新文本字段的用户名字段.目前有一个占位符,其中写有"用户名".我正在从设置文件中加载用户名,但为了清楚起见,我只需在用户名中进行硬编码.
- (void)viewDidLoad {
settings=[Settings new];
[settings loadData];
//username.text=settings.username;
username.text=@"Test";
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,这不起作用!但是,如果我有一个按钮,当我单击它时,它将更新文本字段.
例如
- (IBAction)login:(id)sender{
username.text=@"test";
}
Run Code Online (Sandbox Code Playgroud)
因此按钮更新文本但我无法从viewDidLoad更新.这是一个线程问题吗?我无法相信这么简单的事情需要这么长时间.
我有一个字典词典,它以JSON格式返回给我
{
"neverstart": {
"color": 0,
"count": 0,
"uid": 32387,
"id": 73129,
"name": "neverstart"
},
"dev": {
"color": 0,
"count": 1,
"uid": 32387,
"id": 72778,
"name": "dev"
},
"iphone": {
"color": 0,
"count": 1,
"uid": 32387,
"id": 72777,
"name": "iphone"
}
}
Run Code Online (Sandbox Code Playgroud)
我还有一个NSArray,其中包含项目所需的id.例如[72777,73129]
我需要做的是获取数组中项目的id => name字典.我知道这可以通过迭代数组,然后循环遍历Dictionary中的所有值并检查值,但似乎应该有一个不那么冗长的方法来做到这一点.
请原谅我的无知,因为我只想找到解决iPhone SDK的方法并学习Objective C和Cocoa.
我正在尝试创建一个UITableViewCell,它覆盖了内容的完整绘图.我已经覆盖了正在调用的drawRect,但它仍然绘制了默认内容.
如何让它停止绘制默认内容,如何用自己的渲染替换它?
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
DLog (@"Overloaded TableCell initWithStyle");
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
}
return self;
}
- (void)drawRect:(CGRect)rect {
DLog (@"TableCell::drawRect");
// expecting it to draw nothing
}
Run Code Online (Sandbox Code Playgroud) 是否可以在XSLT中按字母顺序排序,将5个项目作为"首选".
即给定
<teams>
<team id="142" name="Scotland" />
<team id="110" name="Liverpool" />
<team id="13" name="Manchester United" />
<team id="123" name="England" />
<team id="84" name="Chelsea" />
<team id="295" name="Wales" />
<team id="49" name="Arsenal" />
<team id="126" name="Northern Ireland" />
<team id="121" name="Republic of Ireland" />
<team id="42" name="Manchester City" />
<team id="298" name="Tottenham Hotspur" />
<team id="299" name="Bolton" />
</teams>
Run Code Online (Sandbox Code Playgroud)
我要求国家队按照特定顺序排序,其余按字母顺序排列:
<teams>
<team id="123" name="England" />
<team id="126" name="Northern Ireland" />
<team id="121" name="Republic of Ireland" />
<team id="142" name="Scotland" />
<team …Run Code Online (Sandbox Code Playgroud) 当我尝试从Eclipse中运行我的单元测试时,我收到错误"java.lang.IllegalStateExcepton:无法加载应用程序上下文".
单元测试本身看起来很简单:
package com.mycompany.interactive.cs.isales.ispr.ws.productupgrade;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/applicationContext.xml"})
public class ProductUpgradeTest {
@Test
public void getProductUpgrade () throws Exception
{
//System.out.println(PrintClasspath.getClasspathAsString());
Assert.assertTrue(true);
}
}
Run Code Online (Sandbox Code Playgroud)
但不管我似乎做了什么,@ContextConfiguration我仍然得到同样的错误.
applicationContext.xml文件位于文件夹/ etc/ws中,但即使我将副本放在同一个文件夹中,它仍然会给我错误.
我是Java,Spring,Eclipse和Ant的新手,真的不知道这出错了.
我有一个包含敏感信息的课程(信用卡信息,电话号码等).
我希望能够将此类传递给log4j,但让它隐藏某些信息.
如果我有一个具有getPhoneNumber,getCreditCardNumber方法的UserInformation类,我将如何自定义log4j或此类以使其正确地模糊数字.
我希望信用卡号输出为xxxx-xxxx-xxxx-1234,输出的电话号码为xxxx-xxx-xxx,假设这些号码为1234-1234-1234-1234和1234-567-890
谢谢
我正在通过Spring in Action 3工作,并且有一个使用AOP和around方面的例子.
这是Aspect类:
package com.xetius.springIdol;
import org.aspectj.lang.ProceedingJoinPoint;
public class Audience {
public void watchPerformance(ProceedingJoinPoint joinpoint) {
try {
System.out.println("The audience is taking their seats.");
System.out.println("The audience is turning off their cell phones.");
long start = System.currentTimeMillis();
joinpoint.proceed();
long end = System.currentTimeMillis();
System.out.println("CLAP CLAP CLAP CLAP CLAP");
System.out.println("The performance took " + (end - start) + " milliseconds.");
} catch (Throwable e) {
System.out.println("Boo! We want our money back!");
}
}
Run Code Online (Sandbox Code Playgroud)
这是spring xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" …Run Code Online (Sandbox Code Playgroud) Xampp附带了一个名为xampp-portcheck.exe的简洁可执行文件.如果所需端口是空闲的,则响应,如果不是,则在这些端口上运行哪些应用程序.
我可以通过访问netstat详细信息来检查端口上是否正在运行某些内容,但是如何找到在Windows中的端口上运行的应用程序?
我是自定义绘制文本到自定义UITableViewCell,但我正在努力研究如何绘制一行下划线文本.
我目前正在尝试执行以下操作:
CGContextMoveToPoint(context, pt.x, pt.y+sz.height);
CGContextAddLineToPoint(context, pt.x+sz.width, pt.y+sz.height);
Run Code Online (Sandbox Code Playgroud)
但是虽然代码被调用,但实际上并没有绘制.我想我正在做一些愚蠢的事情,但我无法弄明白它是什么.
我有一个带有API的网站,它使用JSON发布信息.我可以很好地访问此API,但我真的希望使用Core Data将信息存储在iPhone应用程序中.有没有办法将持久存储挂钩到JSON API,所以不必使用某种算法让它们保持同步,我只能使用网站作为Core Data的后端.
我希望这很清楚.
我想要一个只包含唯一项目的数组.我知道我可以使用NSDictionary添加带有键的项目,然后获取allKeys.这将确保NSArray只包含唯一的项目,但我觉得这样做太过分了,并且相信应该有一种更简单的方法来做到这一点,但找不到.
我有一些我正在测试的XML,它将日期和时间设置为其中一个元素.这显然会在每次测试运行时发生变化.
有没有办法比较XML并忽略此节点值,或只是用正则表达式或其他东西检查.
我正在测试的XML如下:
<xml-fragment>
<core:date xmlns:core="http://www.company.com/commerce/common/V1/core">2010-06-24T21:41:22.456+01:00</core:date>
<core:serviceName xmlns:core="http://www.company.com/commerce/common/V1/core">calculateNextAndFuturePayments
</core:serviceName>
<core:ackRequired xmlns:core="http://www.company.com/commerce/common/V1/core">false</core:ackRequired>
<v1:viewingCardNumber xmlns:v1="http://www.company.com/commerce/calculateNextAndFuturePayment/V1">405536053
</v1:viewingCardNumber>
</xml-fragment>
Run Code Online (Sandbox Code Playgroud)
我想检查初始元素(核心:日期)是否为日期格式,但这些值与平等目的无关.
谢谢
我无法更新实体中包含的集合.我没有收到任何错误,但是当我尝试使用一组不同的升级实体更新产品时,数据库的内容保持不变.
我有一个Product实体,其中包含一组Upgrade实体.
@Entity
@Table(name="product")
public class Product {
private Long id;
private Set<Upgrade> upgrades;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToMany(mappedBy = "products",
targetEntity = Upgrade.class,
cascade = CascadeType.ALL,
fetch = FetchType.EAGER)
public Set<Upgrade> getUpgrades() {
return upgrades;
}
public void setUpgrades(Set<Upgrade> upgrades) {
this.upgrades = upgrades;
}
}
@Entity
@Table(name="upgrade")
public class Upgrade {
private Long id;
private Set<Product> products;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
public Long getId() …Run Code Online (Sandbox Code Playgroud) java ×6
iphone ×5
cocoa-touch ×3
spring ×3
json ×2
objective-c ×2
aop ×1
aspectj ×1
cocoa ×1
core-data ×1
hibernate ×1
junit ×1
log4j ×1
maven-2 ×1
mysql ×1
networking ×1
nsarray ×1
nsdictionary ×1
perl ×1
sorting ×1
uitableview ×1
uitextfield ×1
windows ×1
xmlunit ×1
xslt ×1