我试图将我的app委托中的对象传递给另一个类中的通知接收器.
我想传递整数messageTotal.现在我有:
在接收器中:
- (void) receiveTestNotification:(NSNotification *) notification
{
if ([[notification name] isEqualToString:@"TestNotification"])
NSLog (@"Successfully received the test notification!");
}
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissSheet) name:UIApplicationWillResignActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveTestNotification:) name:@"eRXReceived" object:nil];
Run Code Online (Sandbox Code Playgroud)
在正在进行通知的类中:
[UIApplication sharedApplication].applicationIconBadgeNumber = messageTotal;
[[NSNotificationCenter defaultCenter] postNotificationName:@"eRXReceived" object:self];
Run Code Online (Sandbox Code Playgroud)
但我想将对象传递messageTotal给另一个类.
cocoa-touch objective-c nsnotifications nsnotificationcenter swift
我正在使用故事板,我有一个UITableView.我有一个segue设置,从我的表推送到细节VC.但是我应该使用哪种方法来处理这个问题?我必须将几个对象传递给详细视图.但我使用didSelectRowAtIndex或-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender?
我正在尝试在我的Lion Mac上安装Xcode 4.1 GM,但它无法正常工作.当它几乎完成时,即使它已经退出,我也会弹出以退出iTunes.因此,我唯一的选择是退出iTunes帮助程序或在活动监视器中发出警报,然后完成安装.然而,Xcode在发布时崩溃了.有任何想法吗?
我正在将CHCSVParser应用到我的iPhone应用程序中(感谢Dave!)但是我真的很困惑如何使用它.我已经阅读了读书并在SO上搜索了一些问题,但仍然不能100%确定要做什么.
我有一个.CSV文件,可能有5000行数据和3-4列.
我希望这些数据作为回报,加载我的UITableView及其相应的detailViewController.
所以我假设我需要以某种方式实现API的数组方法,但任何人都可以帮助我开始吗?
我想记录应用程序版本号,以便在用户发送反馈时,它将在电子邮件中.
我怎么能得到这个号码?
我正在检查网络连接viewDidLoad使用它:
-(BOOL)reachable {
ReachabilityDRC *r = [ReachabilityDRC reachabilityWithHostName:@"google.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
if(internetStatus == NotReachable) {
return NO;
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
但是我也希望在网络发生变化时收到通知,例如wifi掉线或wifi恢复,所以我可以相应地进行更改.
如何调整我的方法来做那样的事情?
我正在尝试从我的.Plist中的数组加载我的数组,但它无法正常工作.
plist看起来像这样:

这是我正在使用的代码:
NSString *path = [[NSBundle mainBundle]pathForResource:@"DiseasePropertyList" ofType:@"plist"];
NSMutableArray *rootLevel = [[NSMutableArray alloc]initWithContentsOfFile:path];
self.myArray = rootLevel;
[rootLevel release];
Run Code Online (Sandbox Code Playgroud) 我正在向我的应用添加核心数据.它说,在下面的方法中Use of undeclared identifier NSSQLiteStoreType
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (__persistentStoreCoordinator != nil)
{
return __persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"tdfas.sqlite"];
NSError *error = nil;
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return __persistentStoreCoordinator;
}
@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
Run Code Online (Sandbox Code Playgroud) 我的应用程序中有一个UISearhBarController.它目前正在搜索在线数据库,但我正在将其更改为搜索核心数据数据库.它目前使用此代码:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
if (self.billingSearchBar == searchBar) {
[self.billingSearchController filterResultsUsingString:searchText];
}
}
- (void)filterResultsUsingString:(NSString *)filterString
{
self.billingSearchText = filterString;
NSArray *billing_codes = [self billingSearch:self.billingSearchText searchType:self.billingSearchCategory];
self.displayedBillingSearch = billing_codes;
self.billingSearch = billing_codes;
[self.tableView reloadData];
}
-(NSMutableArray*)billingSearch:(NSString*)searchString searchType:(NSString*)searchType
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/server/20111115/60b88126/billing_search/", [self getHost]]];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:searchString forKey:@"query"];
[request setPostValue:searchType forKey:@"category"];
[request startSynchronous];
NSError *error = [request error];
NSString *responseString;
if (!error) {
responseString = [request responseString];
}
NSMutableArray …Run Code Online (Sandbox Code Playgroud) iphone cocoa-touch core-data objective-c nsfetchedresultscontroller
我有一个UIViewController,当按下一个按钮时,我想要一个半屏视图,用UIPicker向上滑动.
我在IB中使用UIPicker创建了一个UIView,还有一个带有完成/取消按钮的UIToolBar.
我怎样才能使这个半视图向上滑动,背景视图仍然显示但是暗淡或无法播放.
到目前为止我正在使用此代码:
- (void)showModalView
{
[self.popupView setFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:self.popupView];
[UIView animateWithDuration:.2 animations:^{
[self.popupView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
}];
}
Run Code Online (Sandbox Code Playgroud)
这是一张照片:http://www.box.net/shared/static/08ji4s0f6i1b8qubrtz6.png
iphone xcode objective-c uiviewcontroller modalviewcontroller
objective-c ×9
iphone ×8
xcode ×5
cocoa-touch ×4
app-store ×1
core-data ×1
csv ×1
ios ×1
itunes ×1
nsarray ×1
osx-lion ×1
parsing ×1
plist ×1
reachability ×1
storyboard ×1
swift ×1
uitableview ×1