我在Websphere Application Server 6.0(WAS)内部的Websphere Portal Server中运行了一个应用程序.在这个需要很长时间才能完成的特定功能的应用程序中,我正在触发一个执行此操作的新线程.这个新线程从Hibernate打开一个新的Session,并开始用它执行数据库事务.有时(无法看到模式),线程内的事务工作正常,并且该过程成功完成.其他时候我得到以下错误:
org.hibernate.exception.GenericJDBCException: could not load an entity: [OBJECT NAME#218294]
...
Caused by: com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Connection is closed.
Method cleanup failed while trying to execute method cleanup on ManagedConnection WSRdbManagedConnectionImpl@642aa0d8 from resource jdbc/MyJDBCDataSource. Caught exception: com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by the Data Store Adapter. See original exception message: Cannot call 'cleanup' on a ManagedConnection while it is still in a transaction..
Run Code Online (Sandbox Code Playgroud)
我怎么能阻止这种情况发生?为什么看起来WAS想要杀死我的连接,即使他们没有完成.有没有办法阻止WAS尝试关闭这个特定的连接?
谢谢
我有几个面板包含NSTextField
绑定到File的Owner对象中的属性的控件.如果用户编辑了一个字段,然后按Tab键,要移动到下一个字段,它将按预期工作.但是,如果用户没有按Tab键并按下OK按钮,则不会在File的Owner对象中设置新值.
为了解决这个问题,我在绑定中连续设置了更新,但这必须是昂贵的(编辑:或者至少它是不优雅的).
有没有办法在按下确定按钮时强制绑定更新,而不是连续使用更新?
我正在尝试捕获MapKit引脚选择选择以执行segue到此位置的详细视图,我在注释引脚中有一个属性:
#import <MapKit/MapKit.h>
@interface alrededorLocation : NSObject <MKAnnotation> {
NSString *_name;
NSString *_address;
CLLocationCoordinate2D _coordinate;
NSDictionary *additionalInfo;
}
Run Code Online (Sandbox Code Playgroud)
但是我无法捕获引脚选择以执行segue,我试图控制它 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
但我没有成功获得所选的引脚参考.
非常感谢
我是Objective-C的新手,我正在尝试使用UIImage + Resize类来调整iOS中的图片大小.见UIIimage+Resize.m
代码.
以下代码中的XCode无法识别resizeImage类.
错误消息:"类方法resizedImage:interpolationQuality not found ..."
#import "UIImage+Resize.h"
- (void)useImage:(UIImage*)theImage {
...
...
...
CGSize newSize = CGSizeMake (newWidth, newHeight);
CGInterpolationQuality InterpQual = kCGInterpolationHigh;
UIImage* newImg = [UIImage resizedImage:newSize interpolationQuality:InterpQual];
...
...
...
}
Run Code Online (Sandbox Code Playgroud) 在我的模型对象中,我正在分配这样的日期:
static NSDateFormatter *dateFormat = nil;
if (nil == dateFormat) {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
}
dateCreated = [dateFormat dateFromString:@"2013-03-04 09:16:41"];
Run Code Online (Sandbox Code Playgroud)
我所看到的dateFormat
是永远nil
; 因此,dateCreated
设置为nil
.不知道怎么去调试这个......
我有这个数组,其中必须根据某些条件添加或不添加多个元素。通常我会做这样的事情:
NSMutableArray *myArray = [[NSMutableArray alloc] init];
[myArray addObject:@"aaa"];
[myArray addObject:@"bbb"];
if (flag)
[myArray addObject:@"flag"];
if (box)
[myArray addObject:@"box"];
[myArray addObject:@"xxx"];
if (x > 5)
[myArray addObject:@"smaller"];
if ([self isMenuVisible])
[myArray addObject:@"menu"];
... etc.
Run Code Online (Sandbox Code Playgroud)
但这显得令人困惑和复杂。
我可以想象我可以创建几种方法来做到这一点,但这将涉及传递字典、对象和条件数组等,但所有这些都显得比这更蹩脚和更复杂。
你们如何以更优雅的方式做到这一点?
最近我更新到Xcode 5,现在我的iOS应用程序崩溃了以下代码:
float some_var_a = sinf(...);
float some_var_b = cosf(...);
Run Code Online (Sandbox Code Playgroud)
崩溃日志说明如下:
Dyld Error Message:
Symbol not found: ___sincosf_stret
Referenced from: /var/mobile/Applications/702C8CF3-BB96-41F0-9525-5D65B7A581F3/Magic Encyclopedia: Illusions HD.app/Magic Encyclopedia: Illusions HD
Expected in: /usr/lib/libSystem.B.dylib
Dyld Version: 199.6
Run Code Online (Sandbox Code Playgroud)
据我所知,问题在于编译器进行的sin/cos优化.它试图在___sincosf_stret函数的一次调用中计算sin和cos值,但由于某种原因,libSystem.B.dylib中没有这样的函数.
有人可以帮忙:
1)为什么会发生?
2)如何解决?目前我只是避免在一个地方召唤罪恶和cos,它有效.但这是一个糟糕的解决方案.
我是iOS7开发和目标c的新手,我需要开发一个将3DES加密数据发送到服务器的应用程序,我在堆栈溢出和Net中进行了搜索,但仍然无法正常工作,最后我尝试了此代码,结果我得到了null
+ (NSString*)encrypt:(NSString*)plainText withKey:(NSString*)key{
uint8_t keyByte[kSecrectKeyLength];
NSMutableData *keyData = [[NSMutableData alloc] init];
int i;
for (i=0; i < [key length] / 2; i++) {
NSString *tempNumber = [key substringWithRange: NSMakeRange(i * 2, 2)];
NSScanner *scanner=[NSScanner scannerWithString:tempNumber];
unsigned int temp;
[scanner scanHexInt:&temp];
Byte B = (Byte)(0xFF & temp);
keyByte[i] = B;
}
NSData* data = [plainText dataUsingEncoding:NSUTF8StringEncoding];
size_t plainTextBufferSize = [data length];
const void *vplainText = (const void *)[data bytes];
CCCryptorStatus ccStatus;
uint8_t *bufferPtr = NULL;
size_t bufferPtrSize = 0;
size_t …
Run Code Online (Sandbox Code Playgroud) 我有以下代码生成UICollectionView.当您在UICollectionViewCell上长按时,会出现UIActionSheet.
这有效,但只有一次.如果您关闭UIActionSheet并再次长按同一个单元格,则不会发生任何事情.
我有什么想法我做错了吗?
#import "ProjectsListViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface ProjectsListViewController ()
@end
@implementation ProjectsListViewController
@synthesize appDelegate;
- (void)viewDidLoad
{
[super viewDidLoad];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
// CREATE THE COLLECTION VIEW
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[self setCollectionView:[[UICollectionView alloc] initWithFrame:CGRectMake(20, 54, [[self view] bounds].size.width - 40, [[self view] bounds].size.height) collectionViewLayout:flowLayout]];
[[self collectionView] setDataSource:self];
[[self collectionView] setDelegate:self];
[self.view addSubview:self.collectionView];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
[[self collectionView] setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section
{
return [[[appDelegate userSettingsDictionary] objectForKey:@"Projects"] count];
}
- (NSInteger)numberOfSectionsInCollectionView: …
Run Code Online (Sandbox Code Playgroud) 我的意思是,这看起来像是一种矫枉过正.它已经有了cellForRowForIndexPath
一旦UITableViewSourceDelegate获得了单元格,它就可以通过计算单元格的高度轻松获得高度.
所以为什么?
我需要将其翻译成MIPS汇编(在Mars Assembler上工作)
void mm ( double x[][], double y[][], double z[][], int n)
{
int i,j;
for (i=0; i !=n; i++)
for (j=0; j !=n; j++)
z[i][j] = 0.0;
for (k=0; k !=n; k++)
z[i][j] = z[i][j] + x[i][k] * y[k][j];
}
Run Code Online (Sandbox Code Playgroud) [mutableArray initWithArray: [str componentsSeparatedByString:@" "]];
Run Code Online (Sandbox Code Playgroud)
componentsSeparatedByString
返回一个NSArray *
,并initWithArray
接受一个NSArray *
.
但是,当我运行此代码时,会出现一些错误.有什么问题?