我正在写我的第一个iPhone/Cocoa应用程序.它在导航视图中有两个表视图.当您触摸第一个表视图中的行时,您将进入第二个表视图.我希望第二个视图显示与您在第一个视图中触摸的行相关的CoreData实体的记录.
我在第一个表视图中显示了CoreData数据.您可以触摸一行并转到第二个表格视图.我能够将所选对象的信息从第一个视图传递到第二个视图.但我无法获得第二个视图来进行自己的CoreData获取.对于我的生活,我无法将managedObjectContext对象传递给第二个视图控制器.我不想在第一个视图中执行查找并传递字典,因为我希望能够使用搜索字段来优化第二个视图中的结果,以及从那里向CoreData数据插入新条目.
这是从第一个视图转换到第二个视图的函数.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here -- for example, create and push another view controller.
NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath];
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
secondViewController.tName = [[selectedObject valueForKey:@"name"] description];
secondViewController.managedObjectContext = [self managedObjectContext];
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController release];
}
Run Code Online (Sandbox Code Playgroud)
这是SecondViewController中崩溃的函数:
- (void)viewDidLoad {
[super viewDidLoad];
self.title = tName;
NSError *error;
if (![[self fetchedResultsController] performFetch:&error]) { // <-- crashes here
// Handle the error...
}
}
- (NSFetchedResultsController …Run Code Online (Sandbox Code Playgroud) 我在Eigen :: Vector2f变量中有一堆数据.我想在列中打印它,但我最终会得到不均匀的结果:
Vec1 |Vec2 |Vec3
1.94609 -0.0863508 | 1.71155 -0.137481 |3.00915
1.94609 -0.0863508 |1.57448 1.8755 |387.864
1.94609 -0.0863508 |-0.415677 1.66801 |583.542
2.01589 1.94324 | 1.71155 -0.137481 |433.156
2.01589 1.94324 |1.57448 1.8755 |10.1969
2.01589 1.94324 |-0.415677 1.66801 |303.132
0.00212092 1.966 | 1.71155 -0.137481 |584.061
0.00212092 1.966 |1.57448 1.8755 |124.429
0.00212092 1.966 |-0.415677 1.66801 |17.5172
Run Code Online (Sandbox Code Playgroud)
我正在使用的打印声明是这样的:
Eigen::IOFormat fmt(4, 0, ", ", "\n", "", "");
std::cerr << vec1.transpose().format(fmt) << "\t|" << vec2.transpose().format(fmt) << "\t|" << vec3.transpose().format(fmt) << std::endl;
Run Code Online (Sandbox Code Playgroud)
格式语句的精度似乎表示非零数字的数量,而不是小数位数.例如,如果我将精度设置为2,我会得到像2,-0.044和2.8这样的数字.无论如何,列都没有对齐.
有关如何使我的列对齐的任何想法?所有这些额外空间都来自哪里?
我更新到Parse(1.3.0.1),它不会编译,因为在PFFacebookUtils.h中有一个错误在这行上的包含:
#import <FacebookSDK/FacebookSDK.h>
Run Code Online (Sandbox Code Playgroud)
我安装了Facebook SDK,然后添加了FacebookSDK框架,我就可以编译应用了.但是,由于重复的符号,应用程序没有链接.这是错误转储:
ld: warning: directory not found for option '-L/Users/kevinw/Documents/IOS/JSwipe/Pods/build/Debug-iphoneos'
duplicate symbol _OBJC_IVAR_$_BFAppLinkTarget._URL in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFAppLinkTarget.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFAppLinkTarget.o)
duplicate symbol _OBJC_IVAR_$_BFAppLinkTarget._appStoreId in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFAppLinkTarget.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFAppLinkTarget.o)
duplicate symbol _OBJC_IVAR_$_BFAppLinkTarget._appName in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFAppLinkTarget.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFAppLinkTarget.o)
duplicate symbol _OBJC_METACLASS_$_BFAppLinkTarget in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFAppLinkTarget.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFAppLinkTarget.o)
duplicate symbol _OBJC_CLASS_$_BFAppLinkTarget in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFAppLinkTarget.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFAppLinkTarget.o)
duplicate symbol _OBJC_IVAR_$_BFTaskCompletionSource._task in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFTaskCompletionSource.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFTaskCompletionSource.o)
duplicate symbol _OBJC_CLASS_$_BFTaskCompletionSource in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFTaskCompletionSource.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFTaskCompletionSource.o)
duplicate symbol _OBJC_METACLASS_$_BFTaskCompletionSource in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFTaskCompletionSource.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFTaskCompletionSource.o)
duplicate symbol _OBJC_IVAR_$_BFAppLinkReturnToRefererView._includeStatusBarInSize in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFAppLinkReturnToRefererView.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFAppLinkReturnToRefererView.o)
duplicate symbol _OBJC_IVAR_$_BFAppLinkReturnToRefererView._labelView in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFAppLinkReturnToRefererView.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFAppLinkReturnToRefererView.o)
duplicate symbol _OBJC_IVAR_$_BFAppLinkReturnToRefererView._closeButton in:
/Users/kevinw/Library/Developer/Xcode/DerivedData/JSwipe-ctqmquxfahqdyufengcbtphxyoar/Build/Products/Debug-iphonesimulator/libPods.a(BFAppLinkReturnToRefererView.o)
/Users/kevinw/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFAppLinkReturnToRefererView.o)
duplicate …Run Code Online (Sandbox Code Playgroud) 我需要拆分一个类(.h文件)
#ifndef _L_H
#define _L_H
template<class L> class Myclass{
public:
L();
firstoperator(..);
secondoperator(..);
private:
...
}
template <class L> Myclass<L>::L() ...
template <class L> Myclass<L>::firstoperator(..) ...
template <class L> Myclass<L>::secondoperator(..) ...
Run Code Online (Sandbox Code Playgroud)
在两个不同的.h文件中,格式如下:
#ifndef _L_H
#define _L_H
template<class L> class Myclass{
public:
L();
firstoperator(..);
private:
...
}
template <class L> Myclass<L>::L() ...
template <class L> Myclass<L>::firstoperator(..) ...
Run Code Online (Sandbox Code Playgroud)
#ifndef _L_H
#define _L_H
template<class L> class Myclass{
public:
secondoperator(..);
}
template <class L> Myclass<L>::secondoperator(..) ...
Run Code Online (Sandbox Code Playgroud)
如何在没有冲突的情况下正确完成?
先感谢您.
我刚刚将核心图升级到已经运行成功的应用程序的最新版本.我遵循了相当简单的说明,但是我在UIView.h中遇到了20个语法错误.似乎我并不孤单,但没有人发布过该问题的解决方案.
一个例子:
这段代码来自UIView.h
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);
Run Code Online (Sandbox Code Playgroud)
给出编译错误"'''令牌之前的语法错误":
/var/folders/UO/UOZJs7XuF5iROp2HMSTlz++++TI/-Caches-/com.apple.Xcode.501/CompositeSDKs/iphonesimulator-iPhoneSimulator4.0-drysryiarqddqccmfooifrjfbivi/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:250:0 Syntax error before '^' token in /var/folders/UO/UOZJs7XuF5iROp2HMSTlz++++TI/-Caches-/com.apple.Xcode.501/CompositeSDKs/iphonesimulator-iPhoneSimulator4.0-drysryiarqddqccmfooifrjfbivi/System/Library/Frameworks/UIKit.framework/Headers/UIView.h
Run Code Online (Sandbox Code Playgroud)
它认为该解决方案与构建设置有关.什么会导致这个错误?我不熟悉Objective-C中的(^)语法.
我知道类应该在 hpp 文件中定义。公司惯例要求我将这个特定的类保留在 cpp 文件中。
Doxygen 正在解析有问题的 cpp 文件并在其中记录一些 #define,但完全跳过了该类。我如何让 Doxygen 看到它?我可以在 doxyfile 或文件本身中放入一些内容吗?
以下代码段应该采用PROJECT的值(在Makefile中定义)并创建包含文件名.例如,如果PROJECT = classifier,那么最后它应该为PROJECTINCSTR生成classifier_ir.h
我发现只要我不在后缀中使用下划线,此代码就可以正常工作.但是,使用下划线不是可选的 - 我们的代码库在任何地方都使用它们.我可以解决这个问题,因为PROJECT的值有限,但我想知道如何使用下划线使下面的代码段真正起作用.可以逃脱吗?
#define PROJECT classifier
#define QMAKESTR(x) #x
#define MAKESTR(x) QMAKESTR(x)
#define MAKEINC(x) x ## _ir.h
#define PROJECTINC MAKEINC(PROJECT)
#define PROJECTINCSTR MAKESTR(PROJECTINC)
#include PROJECTINCSTR
Run Code Online (Sandbox Code Playgroud)
编辑:编译器应该尝试包含classifier_ir.h,而不是PROJECT_ir.h.
我有一个QList<QByteArray>我想打印出来的QTextBrowser.QTextBrowser-> append()接受一个QString.
尽管在网上进行了大量的搜索,但我还没有找到将数据转换为QString的方法.
我有一个用Java语言编写的Uint8Array,我想将其内容打印到控制台,例如
255, 19, 42, 0
Run Code Online (Sandbox Code Playgroud)
这是我的代码,当前显示一个空字符串
var bytes = new Uint8Array(data);
var debugBytes = "";
for(var i=0; i<bytes.byteLength; i++) {
debugBytes.concat(bytes[i].toString());
debugBytes.concat(",");
}
console.log('Processing packet [' + bytes[1] + '] ' + debugBytes);
Run Code Online (Sandbox Code Playgroud)
如果设置了断点,我可以在调试器中看到数据,因此字节肯定会被填充。当我尝试通过另一种方法进行打印时,它将所有字节转换为ASCII,但是我的数据大部分不在ASCII可打印范围内。
JavaScript中有与printf()等效的东西吗?
c++ ×3
c ×2
iphone ×2
objective-c ×2
binary-data ×1
class ×1
cocoa-touch ×1
core-data ×1
core-plot ×1
doxygen ×1
eigen ×1
javascript ×1
qt ×1
string ×1
xcode ×1