我有一个名为[self.places objectAtIndex:indexPath.row]的数组; 我试图输出到表中.数组中充满了对象,但是我想使用对象内部的数据,将它们分配给对象的最佳方法是什么?数组内部的数据如下:
<Place:eXMSFqDg7B> {
Location = "<PFGeoPoint: 0x6887480>";
addressline1 = "address line 1";
addressline2 = "address line 2";
agerestrictions = "18+";
email = "test@aol.com";
image = "<PFFile: 0x6887af0>";
name = "Rain NightClub";
phone = 0123456789;
postcode = BT11TG;
type = Club;
}
2012-04-17 00:29:59.501 ClubsNIparse[3517:f803] <Place:95KvPCrSY1> {
Location = "<PFGeoPoint: 0x6888330>";
addressline1 = "address line 1";
addressline2 = "address line 2";
agerestrictions = "18+";
email = "test@aol.com";
image = "<PFFile: 0x6888950>";
name = "Box NightClub";
phone = 0123456789;
postcode …Run Code Online (Sandbox Code Playgroud) 我有一个循环的XML文件集合,并将有错误的文件移动到另一个文件位置.但是,当我使用system.io.file.move函数时,它需要我指定文件名而不是移动文件路径.有没有办法可以将文件从一个位置移动到另一个位置,同时保持相同的名称?我目前正在根据数组中文件的位置创建一个名称,这是不可行的.
string ErrorPath = string.Format(@"{1}ErroredXml{0}.xml", errorLength, errorPaths);
//If type equals "add" then call add method else call update
if (Equals(type, typecomp))
{
//pass object to data access layer to add record
value.addNewGamePlay();
if (value.getGamePlayID() == 0)
{
//move to error file
System.IO.File.Move(value.getFile(), ErrorPath);
errorLength++;
}
}
Run Code Online (Sandbox Code Playgroud) 我试图使用Arrays.binarySearch()方法在字符串数组中找到字符串的索引,但是当查找字符串"Free"时,该方法似乎返回位置整数"-5".知道为什么会这样吗?
String[] names = {"Arken","Ben","Darklark", "Free","group"};
void changeFriends(String uname, boolean b)
{ // change a friend's "online" status
Arrays.sort(names);
int index = Arrays.binarySearch(names, uname);
System.out.println("NAME OF ONLINE USER IS AT INDEX:" + index + "Name:" + uname);
if(index > -1)
{
if(b == true)
{
loggedOn[index] = true;
}
else
{
loggedOn[index] = false;
}
}
// call method to update buttons
changeNameButtons();
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用数组和array.BinarySearch函数验证密码和用户名.数组中的前两个用户名:bradley和john使用函数0和1返回正确的位置.但是当我尝试验证数组jim和clarke中的最后两个字符串时,binarySearch函数返回的用户名位于数组中的位置-2两次导致验证失败.有任何想法吗?
String[] names = {"bradley","john","jim","clarke"};
String[] passwords = {"password","password","test","test"};
int pos = Arrays.binarySearch(names, uname);
System.out.println("Found you in array:" + uname + "here:" + pos);
if(pos >= 0)
{
System.out.println("Validation password for:" + uname);
if(passwords[pos].equals(pword) && !loggedOn[pos])
{
}
Run Code Online (Sandbox Code Playgroud)