1
我有兩個視圖控制器(viewController和popUpViewController)。當我打開應用程序,viewController將加載。它有按鈕。當我點擊按鈕時,圖像將在popUpViewController中打開。然後我點擊popUpViewController上的關閉按鈕,我正在關閉popUpViewController。我的場景是,當我點擊viewController中的按鈕時,我必須打開時間,然後單擊關閉按鈕popUpViewController,我必須採取結束時間。兩者都應存儲在數組中。但數組顯示爲零。我正在使用下面的代碼。從另一個視圖控制器存儲數組值
viewController.m
viewDidLoad中:
fileOpenedValues = @[@"",@"" ,@""];
fileOpenedKeys = @[@"File Name",@"STime",@"ETime"];
fileOpened = [[NSMutableDictionary alloc] initWithObjects:fileOpenedValues forKeys:fileOpenedKeys];
[fileOpenedArr addObject:fileOpened];
-(void) storeArrayFromPopUp :(NSString *)fname second:(NSString *)mname third:(NSString *)lname
{
fileOpenedValues = @[fname ,mname ,lname];
fileOpenedKeys = @[@"File Name",@"STime",@"ETime"];
fileOpened = [[NSMutableDictionary alloc] initWithObjects:fileOpenedValues forKeys:fileOpenedKeys];
[fileOpenedArr addObject:fileOpened];
}
popUpViewController.m
[baseObj storeArrayFromPopUp :openedFileName second:fileOpenStime third:fileOpenEtime];
調用storeArrayFromPopUp後。 fileOpenedArr顯示爲零。
請指教。
你有沒有分配初始化fileOpenedArr之前添加對象.. – krushnsinh
你如何創建basObj。 – Vishnuvardhan
是的,在viewdidload本身。 – VJVJ