我在Core Data上遇到了我的第一个破解,当我在我的设备上运行代码时出现以下错误,但它在模拟器上工作正常.
*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'无法使用nil模型创建NSPersistentStoreCoordinator'
我的一些方法可能导致问题:
- (NSManagedObjectContext *)managedObjectContext
{
if (__managedObjectContext != nil)
{
return __managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil)
{
__managedObjectContext = [[NSManagedObjectContext alloc] init];
[__managedObjectContext setPersistentStoreCoordinator:coordinator];
}
return __managedObjectContext;
}
/**
Returns the managed object model for the application.
If the model doesn't already exist, it is created from the application's model.
*/
- (NSManagedObjectModel *)managedObjectModel
{
if (__managedObjectModel != nil)
{
return __managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"RugbyOnTv" withExtension:@"momd"]; …
Run Code Online (Sandbox Code Playgroud) 我有一个UITableView
和我已经分类UITableViewCell
(称之为CustomCell
)所以它有几个标签和一个UIImageView
.
只有某些单元格才会显示图像.这是我的代码tableView:cellForRowAtIndexPath:
:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Match *aMatch = [[appDelegate.matchByDate objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.homeLabel.text = aMatch.homeTeam;
cell.awayLabel.text = aMatch.awayTeam;
cell.timeLabel.text = aMatch.koTime;
cell.tournamentLabel.text = aMatch.tournament;
NSString *tempString = [appDelegate.teamLogos objectForKey:[aMatch homeTeam]];
if (tempString!=nil) {
cell.homeImageView.image = [UIImage imageNamed:tempString];
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
所以它只设置homeImageView …
我的设置:
我的问题:
如果I vagrant ssh
,然后share domfit.test
得到您所期望的随机生成的ngrok URL(http://whatever.ngrok.io),但是当我访问该URL时,我所有的资源/路由都以http://domfit.test/
(http:// domfit .test / login)
我尝试了以下方法:
php artisan config:clear
php artisan cache:clear
{{ url('login') }}
{{ route('login') }}
我的理解是url()
应该返回浏览器请求的实际URL(而不是使用APP_URL
),但始终返回domfit.test
。
如果我在我的重新命名的网站Homestead.yaml
(例如到newdomfit.test
),并重新规定,那么这是该域url()
和route()
用途的,不管我的APP_URL
。因此,Homestead.yaml
似乎正在强迫该领域。哪个提出了问题-您实际上打算如何使用共享功能?
我是Laravel的新手,所以我不确定是否所有这些都是预期的行为,并且我误会了什么?
我只希望模板中的链接和资源可用于本地(domfit.test
),共享(ngrok
)以及最终使用同一段代码进行生产。我担心的是,当我尝试将该网站上线时,我将不得不更改所有我的信息route()
或url()
参考。
在下面编辑
好的,我只是再试一次。更改APP_URL
为ngrok
:
在我的整个代码库中搜索domfit.test
,并且似乎只有一些随机会话文件具有引用:
代码/ domfit /存储/框架/会话/ …
我正在尝试安排每天(在特定时间,但从明天开始)触发本地通知。
即“从明天起每天晚上8点触发通知”
我一直在使用这个 SO问题作为指导,我相信我正在按照它说的做,但是今天当我运行以下代码时(如果我将通知安排在晚上8点之前),我仍然会收到通知:
func testDateNotification(){
let content = UNMutableNotificationContent()
content.title = "Test"
content.body = "This is a test"
let tomorrow = Calendar.current.date(byAdding: .day, value: 1, to: Date())
let userCalendar = Calendar.current
var components = userCalendar.dateComponents([.hour, .minute], from: tomorrow!)
components.hour = 20
components.minute = 00
let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: true)
let request = UNNotificationRequest(identifier: "test", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request) { (error) in
if ((error) != nil){
print("Error \(String(describing: error))")
}
}
}
Run Code Online (Sandbox Code Playgroud) ios ×3
objective-c ×2
core-data ×1
homestead ×1
laravel ×1
laravel-5 ×1
ngrok ×1
swift ×1
uitableview ×1