基本上在下面的代码中有一个for循环,它产生10个元素,当我点击按钮时,它控制台。记录以下内容:
当前的console.log:
While ThisWorkbook.Worksheets("Inventory Database").Range("A" & j).Value <> ""
If ThisWorkbook.Worksheets("Inventory Database").Range("A" & j) = ThisWorkbook.Worksheets("Equipment Availability").Cells(1, i) Then
dvList = ThisWorkbook.Worksheets("Inventory Database").Range("B" & j)
'~~> Creates the list
With Sheets("Equipment Availability").Cells(2, 2).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=dvList
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
j = j + 1
Wend
(IBAction)btnfb:(id)sender
{
if (!FBSession.activeSession.isOpen)
{
NSArray *_fbPermissions = @[@"email",@"publish_actions",@"public_profile",@"user_hometown",@"user_birthday",@"user_about_me",@"user_friends",@"user_photos",];
[FBSession openActiveSessionWithReadPermissions:_fbPermissions allowLoginUI:YES completionHandler:^(FBSession *session,FBSessionState state, NSError *error)
{
if (error)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else if(session.isOpen)
{
[self btn_fb:sender];
}
}];
return;
}
[FBRequestConnection startWithGraphPath:@"me" parameters:[NSDictionary
dictionaryWithObject:@"cover,picture.type(large),id,name,first_name,last_name,gender,birthday,email,location,hometown,bio,photos"
forKey:@"fields"] HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError
*error)
{
{
if (!error)
{
if ([result isKindOfClass:[NSDictionary class]])
{
NSLog(@"%@",result);
}
}
}
}];
}
Object {objectProperty: "0"}
Object {objectProperty: "1"}
Object {objectProperty: "2"}
Object {objectProperty: "3"}
Object {objectProperty: "4"}
Object {objectProperty: "5"}
Object {objectProperty: "6"}
Object {objectProperty: "7"}
但是我希望对象属性名称是Object {objectProperty: "8"}
的值,所以当我遍历元素时,它将分配一个新的属性名称,该名称与Object {objectProperty: "9"}
值相同。
因此,如果console.log正常工作,它应该看起来像这样:
<span>
<span>
Object {0: "0"}
Object {1: "1"}
Object {2: "2"}
Object {3: "3"}
Object {4: "4"}
Object {5: "5"}
Object {6: "6"}
Object {7: "7"}
到目前为止我有什么:
Object {8: "8"}
Object {9: "9"}
答案 0 :(得分:4)
var obj = {};
obj["<new property name>"] = <new property value>;